10954 | 2024-04-20 18:38:28 | 42 | Vállalati ügyelet | pypy3 | Time limit exceeded 70/100 | 1.075s | 236884 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)-10:
#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 | 48ms | 76312 KiB | ||||
2 | Accepted | 264ms | 181828 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 46ms | 77360 KiB | ||||
4 | Accepted | 46ms | 77668 KiB | ||||
5 | Accepted | 46ms | 77756 KiB | ||||
6 | Accepted | 46ms | 78200 KiB | ||||
subtask3 | 8/8 | ||||||
7 | Accepted | 46ms | 77360 KiB | ||||
8 | Accepted | 46ms | 77668 KiB | ||||
9 | Accepted | 46ms | 77756 KiB | ||||
10 | Accepted | 46ms | 78200 KiB | ||||
11 | Accepted | 208ms | 177268 KiB | ||||
12 | Accepted | 211ms | 177280 KiB | ||||
13 | Accepted | 216ms | 177252 KiB | ||||
14 | Accepted | 222ms | 180588 KiB | ||||
subtask4 | 12/12 | ||||||
15 | Accepted | 46ms | 77360 KiB | ||||
16 | Accepted | 46ms | 77668 KiB | ||||
17 | Accepted | 46ms | 77756 KiB | ||||
18 | Accepted | 46ms | 78200 KiB | ||||
19 | Accepted | 172ms | 183372 KiB | ||||
20 | Accepted | 202ms | 178420 KiB | ||||
21 | Accepted | 202ms | 179396 KiB | ||||
22 | Accepted | 206ms | 185216 KiB | ||||
23 | Accepted | 194ms | 182532 KiB | ||||
24 | Accepted | 190ms | 180320 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 46ms | 77360 KiB | ||||
26 | Accepted | 46ms | 77668 KiB | ||||
27 | Accepted | 46ms | 77756 KiB | ||||
28 | Accepted | 46ms | 78200 KiB | ||||
29 | Accepted | 64ms | 91940 KiB | ||||
30 | Accepted | 68ms | 91836 KiB | ||||
31 | Accepted | 64ms | 91852 KiB | ||||
32 | Accepted | 71ms | 91780 KiB | ||||
33 | Accepted | 75ms | 91848 KiB | ||||
34 | Accepted | 78ms | 92576 KiB | ||||
35 | Accepted | 74ms | 92552 KiB | ||||
36 | Accepted | 67ms | 92304 KiB | ||||
37 | Accepted | 63ms | 92516 KiB | ||||
38 | Accepted | 64ms | 92136 KiB | ||||
39 | Accepted | 74ms | 92700 KiB | ||||
40 | Accepted | 74ms | 92748 KiB | ||||
41 | Accepted | 68ms | 92740 KiB | ||||
subtask6 | 28/28 | ||||||
42 | Accepted | 317ms | 181592 KiB | ||||
43 | Accepted | 372ms | 184316 KiB | ||||
44 | Accepted | 409ms | 184108 KiB | ||||
45 | Accepted | 377ms | 184040 KiB | ||||
46 | Accepted | 294ms | 183324 KiB | ||||
47 | Accepted | 226ms | 183344 KiB | ||||
48 | Accepted | 221ms | 182172 KiB | ||||
49 | Accepted | 203ms | 186244 KiB | ||||
50 | Accepted | 222ms | 183116 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 46ms | 80656 KiB | ||||
52 | Accepted | 266ms | 185116 KiB | ||||
53 | Accepted | 46ms | 77360 KiB | ||||
54 | Accepted | 46ms | 77668 KiB | ||||
55 | Accepted | 46ms | 77756 KiB | ||||
56 | Accepted | 46ms | 78200 KiB | ||||
57 | Accepted | 208ms | 177268 KiB | ||||
58 | Accepted | 211ms | 177280 KiB | ||||
59 | Accepted | 216ms | 177252 KiB | ||||
60 | Accepted | 222ms | 180588 KiB | ||||
61 | Accepted | 172ms | 183372 KiB | ||||
62 | Accepted | 202ms | 178420 KiB | ||||
63 | Accepted | 202ms | 179396 KiB | ||||
64 | Accepted | 206ms | 185216 KiB | ||||
65 | Accepted | 194ms | 182532 KiB | ||||
66 | Accepted | 190ms | 180320 KiB | ||||
67 | Accepted | 64ms | 91940 KiB | ||||
68 | Accepted | 68ms | 91836 KiB | ||||
69 | Accepted | 64ms | 91852 KiB | ||||
70 | Accepted | 71ms | 91780 KiB | ||||
71 | Accepted | 75ms | 91848 KiB | ||||
72 | Accepted | 78ms | 92576 KiB | ||||
73 | Accepted | 74ms | 92552 KiB | ||||
74 | Accepted | 67ms | 92304 KiB | ||||
75 | Accepted | 63ms | 92516 KiB | ||||
76 | Accepted | 64ms | 92136 KiB | ||||
77 | Accepted | 74ms | 92700 KiB | ||||
78 | Accepted | 74ms | 92748 KiB | ||||
79 | Accepted | 68ms | 92740 KiB | ||||
80 | Accepted | 317ms | 181592 KiB | ||||
81 | Accepted | 372ms | 184316 KiB | ||||
82 | Accepted | 409ms | 184108 KiB | ||||
83 | Accepted | 377ms | 184040 KiB | ||||
84 | Accepted | 294ms | 183324 KiB | ||||
85 | Accepted | 226ms | 183344 KiB | ||||
86 | Accepted | 221ms | 182172 KiB | ||||
87 | Accepted | 203ms | 186244 KiB | ||||
88 | Accepted | 222ms | 183116 KiB | ||||
89 | Accepted | 439ms | 193276 KiB | ||||
90 | Accepted | 351ms | 198176 KiB | ||||
91 | Accepted | 398ms | 224208 KiB | ||||
92 | Accepted | 426ms | 236884 KiB | ||||
93 | Time limit exceeded | 1.075s | 94144 KiB | ||||
94 | Time limit exceeded | 1.07s | 89724 KiB | ||||
95 | Accepted | 238ms | 188000 KiB | ||||
96 | Accepted | 472ms | 218900 KiB | ||||
97 | Accepted | 273ms | 186268 KiB | ||||
98 | Accepted | 244ms | 181348 KiB | ||||
99 | Accepted | 284ms | 180060 KiB | ||||
100 | Accepted | 303ms | 179692 KiB | ||||
101 | Accepted | 243ms | 185896 KiB |