[백준] 17472번 - 다리 만들기 2 (파이썬)
# 다리 만들기 2 from collections import deque import sys input = sys.stdin.readline MAX = sys.maxsize dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] N, M = map(int, input().split()) land = [] arr = [] for i in range(N): arr.append(list(map(int, input().split()))) for j in range(M): if arr[i][j] == 1: land.append((i, j)) def find_land(visited, a, b, num): q = deque() q.append((a, b)) while q: x, y = q.popleft(..
2022. 2. 19.
[프로그래머스] - 블록게임 (파이썬)
# 블록게임 import copy dx = [[0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 2, 2]] dy = [[0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]] answer = 0 def solution(board): N = len(board) global answer while True: if not drop_block(board): break return answer def drop_block(arr): N = len(arr) for j in range(N): for i in range(N): if arr[i][j] == -1: continue if arr[i][j] != 0: break arr[i][j] = -1 return check(arr) def check..
2022. 2. 15.