[백준 1944번] 복제 로봇 (Python3)
import sys,collections,heapq input = sys.stdin.readline dy = [1,-1,0,0] dx = [0,0,1,-1] def find(): for y in range(N): for x in range(N): if board[y][x]=="S" or board[y][x]=="K": Index[(y,x)] = len(location) location.append((y,x)) def BFS(y,x,now): cnt = 0 visited = [[0]*N for i in range(N)] dq = collections.deque([(y,x,0)]) while dq: y,x,d = dq.popleft() if visited[y][x]: continue visited[y][x]..
[백준 1933번] 스카이라인 (Python3)
import sys input = sys.stdin.readline from heapq import * N = int(input()) stack = [] hq = [] for i in range(N): heappush(hq,tuple(map(int,input().split()))) end = 0 while hq: l,h,r = heappop(hq) if l >= end: if l > end: stack.append((end,0)) stack.append((l,h)) else: if h != stack[-1][1]: stack.append((l,h)) end = r continue if h end: heappush(hq,(end,h,r)) continue if end > r: heappush(hq,(r,s..
[백준 3860번] 할로윈 묘지 (Python3)
import sys input = sys.stdin.readline from collections import deque dy = [1,-1,0,0] dx = [0,0,1,-1] def BFS(e): visited = [[0]*M for i in range(N)] y,x,t = hole[e] dq = deque([(y,x,0)]) while dq: y,x,d = dq.popleft() if visited[y][x]: continue visited[y][x] = 1 if board[y][x]: graph.append((e,board[y][x],d+t)) continue for i in range(4): y1,x1 = y+dy[i],x+dx[i] if N>y1>=0 and M>x1>=0 and not vis..