목록2024/01/17 (3)
파란색가운의 개발 블로그
import sys # sys.stdin.readline() from collections import deque sys.setrecursionlimit(100000000) import heapq import copy import itertools from itertools import combinations from itertools import permutations INF = 1e9 def findMax(start): q = [] heapq.heappush(q,(0,start)) distance[start] = 0 while q: dist,now = heapq.heappop(q) # now는 노드 번호고 dist는 비용 if distance[now] < dist: continue for i in g..
import sys # sys.stdin.readline() from collections import deque sys.setrecursionlimit(100000000) import heapq import copy import itertools from itertools import combinations from itertools import permutations INF = 1e9 def findMin(): dx = [-1,0,1,0] dy = [0,1,0,-1] # 상하좌우 움직일 수 있으므로!! q = [] heapq.heappush(q,(graph[0][0],0,0)) # 비용, row, col (start) while q: dist,row,col = heapq.heappop(q) # 힙에서..
import sys # sys.stdin.readline() from collections import deque sys.setrecursionlimit(100000000) import heapq import copy import itertools from itertools import combinations from itertools import permutations INF = 1e9 N,M = map(int,sys.stdin.readline().split()) graph = [[INF] *(N+1) for _ in range(N+1)] for _ in range(M): a,b = map(int,sys.stdin.readline().split()) graph[a][b] = 1 # 정순이면 a < b ..