10952 | 2024-04-20 18:34:53 | 42 | Vállalati ügyelet | pypy3 | Time limit exceeded 70/100 | 1.088s | 254460 KiB |
from sys import stdin, stdout
input=stdin.readline
def main():
N = int(input())
P = [0]+list(map(int, input().split()))
A = [0]+list(map(int, input().split()))
res=[1]*(N+1)
for i in range(N,0,-1):
cur=A.pop()
if isinstance(cur,int):
cur={cur}
while res[i] in cur:
cur.remove(res[i])
res[i]+=1
res[P[i]]=max(res[i],res[P[i]])
if isinstance(A[P[i]],int):
cur.add(A[P[i]])
A[P[i]]=cur
else:
if len(A[P[i]]) >= len(cur)+100:
#A[P[i]]=A[P[i]].union(cur)
A[P[i]] |= cur
else:
A[P[i]] = cur.union(A[P[i]])
for i in range(1,N+1):
stdout.write(str(res[i])+' ')
stdout.write('\n')
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 45ms | 76848 KiB | ||||
2 | Accepted | 280ms | 181892 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 39ms | 77580 KiB | ||||
4 | Accepted | 39ms | 77524 KiB | ||||
5 | Accepted | 39ms | 77272 KiB | ||||
6 | Accepted | 39ms | 77616 KiB | ||||
subtask3 | 8/8 | ||||||
7 | Accepted | 39ms | 77580 KiB | ||||
8 | Accepted | 39ms | 77524 KiB | ||||
9 | Accepted | 39ms | 77272 KiB | ||||
10 | Accepted | 39ms | 77616 KiB | ||||
11 | Accepted | 212ms | 177248 KiB | ||||
12 | Accepted | 189ms | 177120 KiB | ||||
13 | Accepted | 187ms | 177244 KiB | ||||
14 | Accepted | 219ms | 196404 KiB | ||||
subtask4 | 12/12 | ||||||
15 | Accepted | 39ms | 77580 KiB | ||||
16 | Accepted | 39ms | 77524 KiB | ||||
17 | Accepted | 39ms | 77272 KiB | ||||
18 | Accepted | 39ms | 77616 KiB | ||||
19 | Accepted | 200ms | 183016 KiB | ||||
20 | Accepted | 177ms | 177808 KiB | ||||
21 | Accepted | 172ms | 179020 KiB | ||||
22 | Accepted | 201ms | 184644 KiB | ||||
23 | Accepted | 222ms | 182260 KiB | ||||
24 | Accepted | 193ms | 179644 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 39ms | 77580 KiB | ||||
26 | Accepted | 39ms | 77524 KiB | ||||
27 | Accepted | 39ms | 77272 KiB | ||||
28 | Accepted | 39ms | 77616 KiB | ||||
29 | Accepted | 64ms | 91716 KiB | ||||
30 | Accepted | 68ms | 91232 KiB | ||||
31 | Accepted | 64ms | 91232 KiB | ||||
32 | Accepted | 78ms | 91404 KiB | ||||
33 | Accepted | 70ms | 91292 KiB | ||||
34 | Accepted | 64ms | 92280 KiB | ||||
35 | Accepted | 74ms | 92448 KiB | ||||
36 | Accepted | 67ms | 91608 KiB | ||||
37 | Accepted | 70ms | 91724 KiB | ||||
38 | Accepted | 68ms | 92312 KiB | ||||
39 | Accepted | 65ms | 92328 KiB | ||||
40 | Accepted | 65ms | 92856 KiB | ||||
41 | Accepted | 64ms | 92200 KiB | ||||
subtask6 | 28/28 | ||||||
42 | Accepted | 300ms | 180632 KiB | ||||
43 | Accepted | 384ms | 183948 KiB | ||||
44 | Accepted | 400ms | 184020 KiB | ||||
45 | Accepted | 337ms | 183900 KiB | ||||
46 | Accepted | 270ms | 183176 KiB | ||||
47 | Accepted | 224ms | 183316 KiB | ||||
48 | Accepted | 221ms | 198056 KiB | ||||
49 | Accepted | 236ms | 186444 KiB | ||||
50 | Accepted | 228ms | 183352 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 48ms | 80420 KiB | ||||
52 | Accepted | 280ms | 185244 KiB | ||||
53 | Accepted | 39ms | 77580 KiB | ||||
54 | Accepted | 39ms | 77524 KiB | ||||
55 | Accepted | 39ms | 77272 KiB | ||||
56 | Accepted | 39ms | 77616 KiB | ||||
57 | Accepted | 212ms | 177248 KiB | ||||
58 | Accepted | 189ms | 177120 KiB | ||||
59 | Accepted | 187ms | 177244 KiB | ||||
60 | Accepted | 219ms | 196404 KiB | ||||
61 | Accepted | 200ms | 183016 KiB | ||||
62 | Accepted | 177ms | 177808 KiB | ||||
63 | Accepted | 172ms | 179020 KiB | ||||
64 | Accepted | 201ms | 184644 KiB | ||||
65 | Accepted | 222ms | 182260 KiB | ||||
66 | Accepted | 193ms | 179644 KiB | ||||
67 | Accepted | 64ms | 91716 KiB | ||||
68 | Accepted | 68ms | 91232 KiB | ||||
69 | Accepted | 64ms | 91232 KiB | ||||
70 | Accepted | 78ms | 91404 KiB | ||||
71 | Accepted | 70ms | 91292 KiB | ||||
72 | Accepted | 64ms | 92280 KiB | ||||
73 | Accepted | 74ms | 92448 KiB | ||||
74 | Accepted | 67ms | 91608 KiB | ||||
75 | Accepted | 70ms | 91724 KiB | ||||
76 | Accepted | 68ms | 92312 KiB | ||||
77 | Accepted | 65ms | 92328 KiB | ||||
78 | Accepted | 65ms | 92856 KiB | ||||
79 | Accepted | 64ms | 92200 KiB | ||||
80 | Accepted | 300ms | 180632 KiB | ||||
81 | Accepted | 384ms | 183948 KiB | ||||
82 | Accepted | 400ms | 184020 KiB | ||||
83 | Accepted | 337ms | 183900 KiB | ||||
84 | Accepted | 270ms | 183176 KiB | ||||
85 | Accepted | 224ms | 183316 KiB | ||||
86 | Accepted | 221ms | 198056 KiB | ||||
87 | Accepted | 236ms | 186444 KiB | ||||
88 | Accepted | 228ms | 183352 KiB | ||||
89 | Accepted | 515ms | 210280 KiB | ||||
90 | Accepted | 509ms | 221492 KiB | ||||
91 | Accepted | 546ms | 229804 KiB | ||||
92 | Accepted | 582ms | 254460 KiB | ||||
93 | Time limit exceeded | 1.088s | 94352 KiB | ||||
94 | Time limit exceeded | 1.049s | 91064 KiB | ||||
95 | Accepted | 248ms | 188040 KiB | ||||
96 | Accepted | 425ms | 217108 KiB | ||||
97 | Accepted | 280ms | 186252 KiB | ||||
98 | Accepted | 284ms | 181168 KiB | ||||
99 | Accepted | 282ms | 180304 KiB | ||||
100 | Accepted | 280ms | 180164 KiB | ||||
101 | Accepted | 277ms | 185964 KiB |