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 | |
| from collections import deque, defaultdict | |
| r, c = map(int, sys.stdin.readline().split()) | |
| maps = [] | |
| for _ in range(r): | |
| maps.append(list(map(int, sys.stdin.readline().split()))) | |
| # 1. 각 섬별로 라벨링하기. | |
| def bfs(start, maps, continent_name): |
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
| cities = int(input()) | |
| _ = int(input()) | |
| parent = {i:i for i in range(1, cities+1)} | |
| def parent_find(x): | |
| if x == parent[x]: | |
| return x | |
| p = parent_find(parent[x]) | |
| parent[x] = p | |
| return parent[x] |
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 defaultdict | |
| nations = sys.stdin.readline().split() | |
| percentage = defaultdict(int) | |
| expected_score = defaultdict(int) | |
| schedule = [] | |
| for _ in range(3): | |
| temp = [] | |
| for _ in range(2): | |
| temp.append(sys.stdin.readline().split()) |
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(budgets, M): | |
| mins, maxs = 0, max(budgets) | |
| answer = 0 | |
| while mins <= maxs: | |
| mid = (mins + maxs) // 2 | |
| temp = [i if i < mid else mid for i in budgets] | |
| if sum(temp) > M: | |
| maxs = mid - 1 | |
| elif sum(temp) <= M: | |
| answer = mid |
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]: |
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
| 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 | |
| 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
| 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
| 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 |