[백준 13907번] 세금 (Python3)
import sys input = sys.stdin.readline from heapq import * N,M,K = map(int,input().split()) start,end = map(int,input().split()) graph = [[] for i in range(N+1)] for _ in range(M): a,b,w = map(int,input().split()) graph[a].append((b,w)) graph[b].append((a,w)) DP,CNT = [1e9]*(N+1),[0]*(N+1) hq = [(0,0,start)] while hq: w,cnt,now = heappop(hq) if DP[now] CNT[now] or DP[cnt][now]
[백준 2254번] 감옥 건설 (Python3)
import sys,math input = sys.stdin.readline from heapq import * def CCW(y1,x1,y2,x2,y3,x3): return (x1-x2)*(y3-y2)-(x3-x2)*(y1-y2) def convexhull(): global co if not co: return inside = False y,x = co[0] if y==Py and x==Px: inside = True convex = [(y,x)]; newco = [] hq = [] for i in range(1,len(co)): yi,xi = co[i] d = math.sqrt((x-xi)**2+(y-yi)**2) heappush(hq,((x-xi)/d,d,yi,xi)) while hq: cos,d,..