10943 | 2024-04-20 17:56:56 | 42 | Vállalati ügyelet | pypy3 | Runtime error 22/100 | 1.093s | 301404 KiB |
from sys import stdin, stdout
input=stdin.readline
def main():
N = int(input())
P = [0]+list(map(int, input().split()))
A = [set()]+[{int(x)} for x in input().split()]
res=[1]*(N+1)
for i in range(N,0,-1):
while res[i] in A[i]:
A[i].remove(res[i])
res[i]+=1
res[P[i]]=max(res[i],res[P[i]])
if len(A[P[i]]) >= len(A[i]):
A[P[i]]=A[P[i]].union(A.pop())
else:
A[P[i]]=A.pop().union(A[P[i]])
#print(A)
#print(A)
print(*res[1:])
#stdout.write(''.join(A))
#stdout.write('\n')
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 43ms | 76112 KiB | ||||
2 | Accepted | 476ms | 249504 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 39ms | 76852 KiB | ||||
4 | Accepted | 39ms | 77096 KiB | ||||
5 | Accepted | 39ms | 77584 KiB | ||||
6 | Accepted | 39ms | 77404 KiB | ||||
subtask3 | 0/8 | ||||||
7 | Accepted | 39ms | 76852 KiB | ||||
8 | Accepted | 39ms | 77096 KiB | ||||
9 | Accepted | 39ms | 77584 KiB | ||||
10 | Accepted | 39ms | 77404 KiB | ||||
11 | Runtime error | 703ms | 301348 KiB | ||||
12 | Runtime error | 867ms | 301404 KiB | ||||
13 | Time limit exceeded | 1.088s | 130428 KiB | ||||
14 | Runtime error | 676ms | 301124 KiB | ||||
subtask4 | 0/12 | ||||||
15 | Accepted | 39ms | 76852 KiB | ||||
16 | Accepted | 39ms | 77096 KiB | ||||
17 | Accepted | 39ms | 77584 KiB | ||||
18 | Accepted | 39ms | 77404 KiB | ||||
19 | Runtime error | 699ms | 300844 KiB | ||||
20 | Runtime error | 897ms | 300932 KiB | ||||
21 | Time limit exceeded | 1.08s | 128272 KiB | ||||
22 | Runtime error | 587ms | 300580 KiB | ||||
23 | Accepted | 356ms | 231976 KiB | ||||
24 | Runtime error | 755ms | 300416 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 39ms | 76852 KiB | ||||
26 | Accepted | 39ms | 77096 KiB | ||||
27 | Accepted | 39ms | 77584 KiB | ||||
28 | Accepted | 39ms | 77404 KiB | ||||
29 | Accepted | 82ms | 93884 KiB | ||||
30 | Accepted | 76ms | 92684 KiB | ||||
31 | Accepted | 68ms | 92324 KiB | ||||
32 | Accepted | 68ms | 93080 KiB | ||||
33 | Accepted | 82ms | 92812 KiB | ||||
34 | Accepted | 71ms | 92476 KiB | ||||
35 | Accepted | 68ms | 92788 KiB | ||||
36 | Accepted | 68ms | 92480 KiB | ||||
37 | Accepted | 74ms | 92924 KiB | ||||
38 | Accepted | 70ms | 93640 KiB | ||||
39 | Accepted | 81ms | 93480 KiB | ||||
40 | Accepted | 72ms | 94028 KiB | ||||
41 | Accepted | 78ms | 93388 KiB | ||||
subtask6 | 0/28 | ||||||
42 | Accepted | 492ms | 280128 KiB | ||||
43 | Accepted | 828ms | 273176 KiB | ||||
44 | Time limit exceeded | 1.093s | 119720 KiB | ||||
45 | Time limit exceeded | 1.055s | 120132 KiB | ||||
46 | Time limit exceeded | 1.055s | 119996 KiB | ||||
47 | Time limit exceeded | 1.021s | 274492 KiB | ||||
48 | Runtime error | 610ms | 298680 KiB | ||||
49 | Runtime error | 578ms | 298432 KiB | ||||
50 | Accepted | 360ms | 233932 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 39ms | 80552 KiB | ||||
52 | Accepted | 541ms | 253380 KiB | ||||
53 | Accepted | 39ms | 76852 KiB | ||||
54 | Accepted | 39ms | 77096 KiB | ||||
55 | Accepted | 39ms | 77584 KiB | ||||
56 | Accepted | 39ms | 77404 KiB | ||||
57 | Runtime error | 703ms | 301348 KiB | ||||
58 | Runtime error | 867ms | 301404 KiB | ||||
59 | Time limit exceeded | 1.088s | 130428 KiB | ||||
60 | Runtime error | 676ms | 301124 KiB | ||||
61 | Runtime error | 699ms | 300844 KiB | ||||
62 | Runtime error | 897ms | 300932 KiB | ||||
63 | Time limit exceeded | 1.08s | 128272 KiB | ||||
64 | Runtime error | 587ms | 300580 KiB | ||||
65 | Accepted | 356ms | 231976 KiB | ||||
66 | Runtime error | 755ms | 300416 KiB | ||||
67 | Accepted | 82ms | 93884 KiB | ||||
68 | Accepted | 76ms | 92684 KiB | ||||
69 | Accepted | 68ms | 92324 KiB | ||||
70 | Accepted | 68ms | 93080 KiB | ||||
71 | Accepted | 82ms | 92812 KiB | ||||
72 | Accepted | 71ms | 92476 KiB | ||||
73 | Accepted | 68ms | 92788 KiB | ||||
74 | Accepted | 68ms | 92480 KiB | ||||
75 | Accepted | 74ms | 92924 KiB | ||||
76 | Accepted | 70ms | 93640 KiB | ||||
77 | Accepted | 81ms | 93480 KiB | ||||
78 | Accepted | 72ms | 94028 KiB | ||||
79 | Accepted | 78ms | 93388 KiB | ||||
80 | Accepted | 492ms | 280128 KiB | ||||
81 | Accepted | 828ms | 273176 KiB | ||||
82 | Time limit exceeded | 1.093s | 119720 KiB | ||||
83 | Time limit exceeded | 1.055s | 120132 KiB | ||||
84 | Time limit exceeded | 1.055s | 119996 KiB | ||||
85 | Time limit exceeded | 1.021s | 274492 KiB | ||||
86 | Runtime error | 610ms | 298680 KiB | ||||
87 | Runtime error | 578ms | 298432 KiB | ||||
88 | Accepted | 360ms | 233932 KiB | ||||
89 | Runtime error | 503ms | 298404 KiB | ||||
90 | Runtime error | 479ms | 298508 KiB | ||||
91 | Runtime error | 469ms | 298464 KiB | ||||
92 | Runtime error | 488ms | 298248 KiB | ||||
93 | Time limit exceeded | 1.082s | 119316 KiB | ||||
94 | Runtime error | 626ms | 298276 KiB | ||||
95 | Runtime error | 518ms | 298384 KiB | ||||
96 | Runtime error | 721ms | 298428 KiB | ||||
97 | Accepted | 620ms | 269340 KiB | ||||
98 | Accepted | 453ms | 239360 KiB | ||||
99 | Accepted | 500ms | 242224 KiB | ||||
100 | Accepted | 670ms | 261928 KiB | ||||
101 | Accepted | 597ms | 247784 KiB |