Contest Duration: ~ (local time) (180 minutes)

Submission #13244618

Source Code Expand

Copy
```q=range;n,m,k=map(int,input().split())
p=list(map(int,input().split()))
e=[[]for _ in q(n)]
for i in q(n):
if p[i]:e[p[i]-1].append(i)
else:r=i
def bfs(v,t):
c=[r];d=[0]*n;d[r]=1;x=[1];a=-1
if t==r:return[[],1]
for i in c:
for j in e[i]:
if j==t:a=d[i]+1;continue
if j not in v:c.append(j);d[j]=d[i]+1;x.append(d[j])
return[sorted(x),a]
v=set();z=[]
for i in q(m):
w=m-i-1
for j in q(n+1):
if j==n:z=[-1]
x,a=bfs(v,j)
if a<1or len(x)<w or j in v:continue
print(*z)```

#### Submission Info

Submission Time 2020-05-16 11:54:24+0900 F - Coins on the tree tyawanmusi PyPy3 (2.4.0) 0 605 Byte WA 616 ms 49556 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt
All 0 / 400 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt 213 ms 41840 KB
02.txt 172 ms 38256 KB
03.txt 184 ms 39408 KB
04.txt 216 ms 41840 KB
05.txt 186 ms 39664 KB
06.txt 244 ms 43740 KB
07.txt 234 ms 43356 KB
08.txt 273 ms 45404 KB
09.txt 254 ms 43884 KB
10.txt 492 ms 46556 KB
11.txt 296 ms 45788 KB
12.txt 376 ms 45148 KB
13.txt 470 ms 45148 KB
14.txt 400 ms 45656 KB
15.txt 281 ms 44124 KB
16.txt 497 ms 45788 KB
17.txt 350 ms 46768 KB
18.txt 604 ms 47836 KB
19.txt 489 ms 45532 KB
20.txt 579 ms 47836 KB
21.txt 378 ms 44508 KB
22.txt 616 ms 45916 KB
23.txt 593 ms 45788 KB
24.txt 590 ms 46172 KB
25.txt 594 ms 46044 KB
26.txt 545 ms 46556 KB
27.txt 589 ms 49556 KB
28.txt 553 ms 46300 KB
29.txt 588 ms 47836 KB
30.txt 518 ms 45148 KB
31.txt 222 ms 42480 KB
32.txt 201 ms 40304 KB
33.txt 235 ms 44144 KB
34.txt 195 ms 40816 KB
35.txt 282 ms 46300 KB
36.txt 205 ms 40688 KB
37.txt 175 ms 38768 KB
38.txt 177 ms 38768 KB
39.txt 188 ms 39280 KB
40.txt 185 ms 39152 KB
s1.txt 170 ms 38256 KB
s2.txt 169 ms 38256 KB