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 = int(sys.stdin.readline()) | |
| maps = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] | |
| # 해당 좌표로 이동할 수 있는 방법의 개수 | |
| table = [[0 for _ in range(n)] for _ in range(n)] | |
| # 시작지점은 1로 정의 | |
| table[0][0] = 1 | |
| for y in range(n): | |
| for x in range(n): |
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, m = map(int, sys.stdin.readline().split()) | |
| maps = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] | |
| answer = 0 | |
| def check_shape(maps, shape): | |
| global answer | |
| y_length = len(maps) - len(shape) | |
| x_length = len(maps[0]) - len(shape[0]) | |
| for start_y in range(y_length + 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(msg): | |
| table = dict() | |
| for idx, value in enumerate("ABCDEFGHIJKLMNOPQRSTUVWXYZ",1): | |
| table[value] = idx | |
| last_idx = idx | |
| idx = 1 | |
| answer = [] | |
| letter = msg[0] | |
| while idx < len(msg): | |
| # 현재 입력 + 다음 글자 조합이 색인에 없는 경우 |
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 | |
| def bfs(start, maps, visited): | |
| queue = deque() | |
| queue.append(start) | |
| while queue: | |
| y = queue.popleft() | |
| visited.add(y) | |
| for x in range(1, len(maps[y])): |
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 | |
| import math | |
| from itertools import combinations | |
| n = int(sys.stdin.readline()) | |
| populations = list(map(int, sys.stdin.readline().split())) | |
| populations.insert(0, 0) | |
| maps = [[0 for _ in range(n+1)] 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
| import sys | |
| from itertools import chain | |
| from copy import deepcopy | |
| n = int(sys.stdin.readline()) | |
| maps = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] | |
| max_value = 0 | |
| # 앞으로 기울이기 - 0 | |
| # 뒤로 기울이기 - 1 | |
| # 오른쪽으로 기울이기 - 2 |
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 | |
| def bfs(start, connected): | |
| queue = deque() | |
| queue.append(start) | |
| visited = [0 for _ in range(N+1)] | |
| count = 1 | |
| while queue: | |
| current = queue.popleft() |
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. 모든 경우의 수 |