# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
147154 |
2019-08-28T06:11:33 Z |
jh05013 |
Wand (COCI19_wand) |
PyPy |
|
300 ms |
31252 KB |
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 |
1 |
Correct |
33 ms |
11224 KB |
Output is correct |
2 |
Correct |
33 ms |
11108 KB |
Output is correct |
3 |
Correct |
281 ms |
31224 KB |
Output is correct |
4 |
Correct |
272 ms |
30080 KB |
Output is correct |
5 |
Correct |
277 ms |
30476 KB |
Output is correct |
6 |
Correct |
291 ms |
29912 KB |
Output is correct |
7 |
Correct |
278 ms |
30084 KB |
Output is correct |
8 |
Correct |
300 ms |
30920 KB |
Output is correct |
9 |
Correct |
211 ms |
23004 KB |
Output is correct |
10 |
Correct |
286 ms |
31252 KB |
Output is correct |