This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
def solution(n, weak, dist): | |
# 1. 시계 / 반시계 문제 해결하기 | |
weak_length = len(weak) | |
for i in range(weak_length): | |
weak.append(weak[i] + n) | |
# 4에서 반시계방향 = 9에서 시계방향. | |
# 즉 길이를 두 배 늘려놓으면 굳이 방향 고민할 필요 없다 | |
# 투입할 수 있는 친구의 최댓값. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from collections import deque | |
n = int(sys.stdin.readline()) | |
maps = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] | |
# y 기준으로 x 탐색 | |
def bfs(start, end, maps): | |
queue = deque() | |
queue.append(start) | |
visited = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from itertools import permutations | |
from collections import deque | |
from copy import deepcopy | |
import math | |
y, x, n = map(int, sys.stdin.readline().split()) | |
original_maps = [list(map(int, sys.stdin.readline().split())) for _ in range(y)] | |
arrs = [list(map(int,sys.stdin.readline().split())) for _ in range(n)] | |
# 1. 모든 경우의 수 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(left, right): | |
left.insert(0,0) | |
right.insert(0,0) | |
# table[leftidx][rightidx] = left에서 idx빼낼 때, right에서 idx개 빼낼 때 최댓값. | |
table = [[0 for _ in range(len(right))] for _ in range(len(left))] | |
for y in range(1, len(left)): | |
for x in range(1, len(right)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque, defaultdict | |
import math | |
import sys | |
sys.setrecursionlimit(10**6) | |
def find_parent(x, parent): | |
if x == parent[x]: | |
return x | |
else: | |
p = find_parent(parent[x], parent) | |
parent[x] = p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import math | |
n, m = map(int, sys.stdin.readline().split()) | |
maps = [] | |
for y in range(n): | |
arr = list(sys.stdin.readline()) | |
maps.append(arr) | |
for x in range(len(arr)): | |
if arr[x] == 'R': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
n, c = map(int, sys.stdin.readline().split()) | |
arr = [] | |
for _ in range(n): | |
arr.append(int(sys.stdin.readline())) | |
arr.sort() | |
start, end = 1, arr[-1] - arr[0] | |
result = 0 | |
while start <= end: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(n, words): | |
# 처음으로 말한 단어 저장 | |
dataset = set([words[0]]) | |
# 이전 단어 기억 | |
prev_words = words[0] | |
for i in range(1,len(words)): | |
# 이전 단어의 마지막 글자와 제시단어의 첫글자가 다르거나, 이미 있는 단어일 경우 | |
if (prev_words[-1] != words[i][0]) or words[i] in dataset: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from itertools import permutations | |
end = int(sys.stdin.readline()) | |
inning = [list(map(int, sys.stdin.readline().split())) for _ in range(end)] | |
max_score = 0 | |
def game(line_ups): | |
hitter_idx = 0 | |
score = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from collections import deque | |
n, _ = map(int, sys.stdin.readline().split()) | |
numbers = list(map(int, sys.stdin.readline().split())) | |
queue = deque(range(1, n+1)) | |
total_compute = 0 | |
for idx in range(len(numbers)): | |
if numbers[idx] == queue[0]: |