제출 #1171900

#제출 시각아이디문제언어결과실행 시간메모리
1171900IsamNaboj (COCI22_naboj)Pypy 3
110 / 110
712 ms91920 KiB
from collections import deque def main(): n, m = map(int, input().split()) cnt = [0] * (n + 1) g = [[] for _ in range(n + 1)] em = [] q = deque() for _ in range(m): a, b = map(int, input().split()) g[b].append(a) cnt[a] += 1 for i in range(1, n + 1): if cnt[i] == 0: q.append(i) while q: cur = q.popleft() em.append(cur) for to in g[cur]: cnt[to] -= 1 if cnt[to] == 0: q.append(to) if len(em) != n: print(-1) else: print(n) for to in em: print(to, 1) if __name__ == "__main__": main()

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'naboj.py'...

=======
  adding: __main__.pyc (deflated 33%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...