# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147154 | jh05013 | Wand (COCI19_wand) | Pypy 2 | 300 ms | 31252 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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... |