10951 | 2024-04-20 18:32:10 | 42 | Vállalati ügyelet | pypy3 | Time limit exceeded 70/100 | 1.05s | 250596 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 | 50ms | 76544 KiB | ||||
2 | Accepted | 280ms | 181828 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 46ms | 77348 KiB | ||||
4 | Accepted | 43ms | 77544 KiB | ||||
5 | Accepted | 39ms | 77680 KiB | ||||
6 | Accepted | 46ms | 78024 KiB | ||||
subtask3 | 8/8 | ||||||
7 | Accepted | 46ms | 77348 KiB | ||||
8 | Accepted | 43ms | 77544 KiB | ||||
9 | Accepted | 39ms | 77680 KiB | ||||
10 | Accepted | 46ms | 78024 KiB | ||||
11 | Accepted | 207ms | 178156 KiB | ||||
12 | Accepted | 210ms | 177748 KiB | ||||
13 | Accepted | 189ms | 177652 KiB | ||||
14 | Accepted | 259ms | 180936 KiB | ||||
subtask4 | 12/12 | ||||||
15 | Accepted | 46ms | 77348 KiB | ||||
16 | Accepted | 43ms | 77544 KiB | ||||
17 | Accepted | 39ms | 77680 KiB | ||||
18 | Accepted | 46ms | 78024 KiB | ||||
19 | Accepted | 173ms | 183572 KiB | ||||
20 | Accepted | 202ms | 178596 KiB | ||||
21 | Accepted | 179ms | 180212 KiB | ||||
22 | Accepted | 201ms | 185660 KiB | ||||
23 | Accepted | 221ms | 182844 KiB | ||||
24 | Accepted | 193ms | 180660 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 46ms | 77348 KiB | ||||
26 | Accepted | 43ms | 77544 KiB | ||||
27 | Accepted | 39ms | 77680 KiB | ||||
28 | Accepted | 46ms | 78024 KiB | ||||
29 | Accepted | 64ms | 92408 KiB | ||||
30 | Accepted | 59ms | 91992 KiB | ||||
31 | Accepted | 61ms | 92168 KiB | ||||
32 | Accepted | 64ms | 92400 KiB | ||||
33 | Accepted | 67ms | 91968 KiB | ||||
34 | Accepted | 64ms | 92812 KiB | ||||
35 | Accepted | 65ms | 92912 KiB | ||||
36 | Accepted | 63ms | 92108 KiB | ||||
37 | Accepted | 63ms | 92356 KiB | ||||
38 | Accepted | 65ms | 92652 KiB | ||||
39 | Accepted | 67ms | 92660 KiB | ||||
40 | Accepted | 64ms | 93120 KiB | ||||
41 | Accepted | 64ms | 92360 KiB | ||||
subtask6 | 28/28 | ||||||
42 | Accepted | 331ms | 181536 KiB | ||||
43 | Accepted | 358ms | 184468 KiB | ||||
44 | Accepted | 386ms | 184300 KiB | ||||
45 | Accepted | 381ms | 184272 KiB | ||||
46 | Accepted | 268ms | 183680 KiB | ||||
47 | Accepted | 221ms | 183652 KiB | ||||
48 | Accepted | 218ms | 182568 KiB | ||||
49 | Accepted | 202ms | 186488 KiB | ||||
50 | Accepted | 194ms | 183560 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 39ms | 80420 KiB | ||||
52 | Accepted | 275ms | 185032 KiB | ||||
53 | Accepted | 46ms | 77348 KiB | ||||
54 | Accepted | 43ms | 77544 KiB | ||||
55 | Accepted | 39ms | 77680 KiB | ||||
56 | Accepted | 46ms | 78024 KiB | ||||
57 | Accepted | 207ms | 178156 KiB | ||||
58 | Accepted | 210ms | 177748 KiB | ||||
59 | Accepted | 189ms | 177652 KiB | ||||
60 | Accepted | 259ms | 180936 KiB | ||||
61 | Accepted | 173ms | 183572 KiB | ||||
62 | Accepted | 202ms | 178596 KiB | ||||
63 | Accepted | 179ms | 180212 KiB | ||||
64 | Accepted | 201ms | 185660 KiB | ||||
65 | Accepted | 221ms | 182844 KiB | ||||
66 | Accepted | 193ms | 180660 KiB | ||||
67 | Accepted | 64ms | 92408 KiB | ||||
68 | Accepted | 59ms | 91992 KiB | ||||
69 | Accepted | 61ms | 92168 KiB | ||||
70 | Accepted | 64ms | 92400 KiB | ||||
71 | Accepted | 67ms | 91968 KiB | ||||
72 | Accepted | 64ms | 92812 KiB | ||||
73 | Accepted | 65ms | 92912 KiB | ||||
74 | Accepted | 63ms | 92108 KiB | ||||
75 | Accepted | 63ms | 92356 KiB | ||||
76 | Accepted | 65ms | 92652 KiB | ||||
77 | Accepted | 67ms | 92660 KiB | ||||
78 | Accepted | 64ms | 93120 KiB | ||||
79 | Accepted | 64ms | 92360 KiB | ||||
80 | Accepted | 331ms | 181536 KiB | ||||
81 | Accepted | 358ms | 184468 KiB | ||||
82 | Accepted | 386ms | 184300 KiB | ||||
83 | Accepted | 381ms | 184272 KiB | ||||
84 | Accepted | 268ms | 183680 KiB | ||||
85 | Accepted | 221ms | 183652 KiB | ||||
86 | Accepted | 218ms | 182568 KiB | ||||
87 | Accepted | 202ms | 186488 KiB | ||||
88 | Accepted | 194ms | 183560 KiB | ||||
89 | Accepted | 389ms | 205080 KiB | ||||
90 | Accepted | 393ms | 216064 KiB | ||||
91 | Accepted | 541ms | 223620 KiB | ||||
92 | Accepted | 583ms | 250596 KiB | ||||
93 | Time limit exceeded | 1.049s | 94396 KiB | ||||
94 | Time limit exceeded | 1.05s | 91332 KiB | ||||
95 | Accepted | 236ms | 187948 KiB | ||||
96 | Accepted | 476ms | 219248 KiB | ||||
97 | Accepted | 287ms | 186012 KiB | ||||
98 | Accepted | 287ms | 181112 KiB | ||||
99 | Accepted | 272ms | 180116 KiB | ||||
100 | Accepted | 282ms | 179596 KiB | ||||
101 | Accepted | 252ms | 185640 KiB |