또상정렬. heap써서 완전한 위상정렬은 아니고 그냥 앞숫자부터 빼주는위상정렬. import sys input = sys.stdin.readline from heapq import heappop,heappush def topological_sort(): heap=[] for i in range(1,N+1): if not level[i]: heappush(heap,i) while heap: cur_solve = heappop(heap) answer.append(cur_solve) for next_solve in ordered[cur_solve]: level[next_solve] -=1 if not level[next_solve]: heappush(heap,next_solve) # 문제는 모두 풀어야한다. ..