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 chain | |
def solution(board): | |
height = len(board) | |
width = len(board[0]) | |
for i in range(1, height): | |
for j in range(1, width): | |
mins = min(board[i-1][j-1], board[i-1][j], board[i][j-1]) | |
if board[i][j] == 0 or mins == 0: | |
continue | |
board[i][j] = max(mins + 1, board[i][j]) |
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()) | |
arr = [] | |
for _ in range(n): | |
arr.append(list(map(int, sys.stdin.readline().split()))) | |
table = [[0 for _ in range(3)] for _ in range(n)] | |
for i in range(n): | |
for j in range(3): | |
if i == 0: | |
table[i][j] = arr[i][j] |
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, m = map(int, sys.stdin.readline().split()) | |
maps = [[] for _ in range(n+1)] | |
# 각 도시의 연결여부와 무게제한을 저장하는 배열 생성 | |
for _ in range(m): | |
y, x, w = map(int, sys.stdin.readline().split()) | |
maps[y].append((x,w)) | |
maps[x].append((y,w)) |
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()) | |
schedule = [] | |
for _ in range(n): | |
d, value = map(int, sys.stdin.readline().split()) | |
schedule.append((d, value)) | |
# 시작 가능한 날짜들만 설정. 각 날짜마다의 기준값이 된다. | |
table = [schedule[i][1] if schedule[i][0] + i - 1 < n else 0 for i in range(n)] | |
for date 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
# table[y][x] = 0부터 y까지의 화폐로 i원을 내는 법 | |
def solution(n, money): | |
table = [[0 for _ in range(n+1)] for _ in range(len(money))] | |
table[0][0] = 1 | |
# 동전의 최솟값으로 만들 수 있는 값들. 최소 동전이 1이 아닌 경우도 있을 수 있으므로. | |
for i in range(money[0], n+1, money[0]): | |
table[0][i] = 1 | |
for y in range(1, len(money)): | |
for x in range(n+1): | |
if x >= money[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
n = int(input()) | |
answer = 0 | |
for _ in range(n): | |
# 각 단어별로 확인하기 | |
string = list(input()) | |
# 첫 글자는 table에 바로 저장 | |
prev = string.pop(0) | |
table = set(prev) | |
# 그룹 단어인지 체크하는 Bool | |
is_group = True |
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)] | |
# 가로, 세로, 대각선의 idx를 각각 0, 1, 2로 설정. | |
table = [[[0]*3 for _ in range(n)] for _ in range(n)] | |
# 파이프의 오른쪽 끝만 도착하면 되기 때문에, 파이프 오른쪽을 기준으로 설정 | |
table[0][1][0] = 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
from itertools import combinations | |
from copy import deepcopy | |
import sys | |
N, M, D = map(int, sys.stdin.readline().split()) | |
# 적군의 위치를 저장하는 set | |
enemy_position = set() | |
for y in range(N): | |
arr = list(map(int, sys.stdin.readline().split())) | |
for x in range(M): |
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 | |
# 문제의 경우 1은 시계방향, -1은 반시계 방향이다. | |
# deque의 rotate = -1일 경우 반시계 방향, 1일 경우 시계 방향으로 움직인다. | |
def check_right(start, dirs): | |
# 더 이상 조사가 불가능한 경우 | |
if start > 4 or gears[start-1][2] == gears[start][6]: | |
return |
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): | |
table = dict() | |
table[0], table[1] = 1, 1 | |
for i in range(2, n+1): | |
table[i] = table[i-1] + table[i-2] | |
return table[n] % 1234567 |