# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
147154 | jh05013 | Wand (COCI19_wand) | Pypy 2 | 300 ms | 31252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
from __future__ import print_function
input = raw_input
range = xrange
n, m = map(int,input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
a, b = map(int,input().split())
adj[b].append(a)
if not adj[1]:
print('1' + '0'*(n-1))
exit()
vis = [False]*(n+1); vis[1] = True
stack = [1]
while stack:
p = stack.pop()
for q in adj[p]:
if vis[q]: continue
vis[q] = True; stack.append(q)
vis[1] = any((vis[p] and (1 in adj[p])) for p in range(2, n+1))
for x in vis[1:]:
print(int(x), end='')
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |