반응형
Notice
Recent Posts
Recent Comments
Link
목록위상정렬 (1)
It's easy, if you try
[백준/boj] 1766: 문제집 (Python) / 위상정렬
문제링크: https://www.acmicpc.net/problem/1766 풀이 import sys input = sys.stdin.readline import heapq n, m = map(int, input().split()) tree = [[] for _ in range(n+1)] inDegree = [0 for _ in range(n+1)] for _ in range(m): a, b = map(int, input().split()) tree[a].append(b) inDegree[b] += 1 q = [] for i in range(1,n+1): if inDegree[i] == 0: # 차수가 0 인 문제를 최소 힙에 push heapq.heappush(q, i) result = [] while..
알고리즘/파이썬(Python)
2021. 7. 3. 01:15