Submission #147154

#TimeUsernameProblemLanguageResultExecution timeMemory
147154jh05013Wand (COCI19_wand)Pypy 2
70 / 70
300 ms31252 KiB
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 timeMemoryGrader output
Fetching results...