10949 | 2024-04-20 18:22:06 | 42 | Vállalati ügyelet | pypy3 | Time limit exceeded 70/100 | 1.07s | 241200 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):
#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 | 41ms | 76348 KiB | ||||
2 | Accepted | 289ms | 181540 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 43ms | 77128 KiB | ||||
4 | Accepted | 46ms | 77268 KiB | ||||
5 | Accepted | 46ms | 77528 KiB | ||||
6 | Accepted | 43ms | 77744 KiB | ||||
subtask3 | 8/8 | ||||||
7 | Accepted | 43ms | 77128 KiB | ||||
8 | Accepted | 46ms | 77268 KiB | ||||
9 | Accepted | 46ms | 77528 KiB | ||||
10 | Accepted | 43ms | 77744 KiB | ||||
11 | Accepted | 206ms | 177516 KiB | ||||
12 | Accepted | 187ms | 177332 KiB | ||||
13 | Accepted | 187ms | 177800 KiB | ||||
14 | Accepted | 221ms | 180964 KiB | ||||
subtask4 | 12/12 | ||||||
15 | Accepted | 43ms | 77128 KiB | ||||
16 | Accepted | 46ms | 77268 KiB | ||||
17 | Accepted | 46ms | 77528 KiB | ||||
18 | Accepted | 43ms | 77744 KiB | ||||
19 | Accepted | 200ms | 183600 KiB | ||||
20 | Accepted | 178ms | 178484 KiB | ||||
21 | Accepted | 173ms | 179768 KiB | ||||
22 | Accepted | 201ms | 185288 KiB | ||||
23 | Accepted | 196ms | 182592 KiB | ||||
24 | Accepted | 193ms | 180516 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 43ms | 77128 KiB | ||||
26 | Accepted | 46ms | 77268 KiB | ||||
27 | Accepted | 46ms | 77528 KiB | ||||
28 | Accepted | 43ms | 77744 KiB | ||||
29 | Accepted | 64ms | 92360 KiB | ||||
30 | Accepted | 71ms | 91992 KiB | ||||
31 | Accepted | 64ms | 91796 KiB | ||||
32 | Accepted | 71ms | 92112 KiB | ||||
33 | Accepted | 70ms | 92048 KiB | ||||
34 | Accepted | 64ms | 92796 KiB | ||||
35 | Accepted | 64ms | 92072 KiB | ||||
36 | Accepted | 63ms | 91948 KiB | ||||
37 | Accepted | 70ms | 92236 KiB | ||||
38 | Accepted | 68ms | 92080 KiB | ||||
39 | Accepted | 65ms | 92356 KiB | ||||
40 | Accepted | 65ms | 92168 KiB | ||||
41 | Accepted | 64ms | 92100 KiB | ||||
subtask6 | 28/28 | ||||||
42 | Accepted | 286ms | 181116 KiB | ||||
43 | Accepted | 349ms | 183860 KiB | ||||
44 | Accepted | 384ms | 183568 KiB | ||||
45 | Accepted | 337ms | 184100 KiB | ||||
46 | Accepted | 303ms | 183348 KiB | ||||
47 | Accepted | 248ms | 183224 KiB | ||||
48 | Accepted | 224ms | 182192 KiB | ||||
49 | Accepted | 236ms | 186124 KiB | ||||
50 | Accepted | 222ms | 183196 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 41ms | 80116 KiB | ||||
52 | Accepted | 261ms | 184996 KiB | ||||
53 | Accepted | 43ms | 77128 KiB | ||||
54 | Accepted | 46ms | 77268 KiB | ||||
55 | Accepted | 46ms | 77528 KiB | ||||
56 | Accepted | 43ms | 77744 KiB | ||||
57 | Accepted | 206ms | 177516 KiB | ||||
58 | Accepted | 187ms | 177332 KiB | ||||
59 | Accepted | 187ms | 177800 KiB | ||||
60 | Accepted | 221ms | 180964 KiB | ||||
61 | Accepted | 200ms | 183600 KiB | ||||
62 | Accepted | 178ms | 178484 KiB | ||||
63 | Accepted | 173ms | 179768 KiB | ||||
64 | Accepted | 201ms | 185288 KiB | ||||
65 | Accepted | 196ms | 182592 KiB | ||||
66 | Accepted | 193ms | 180516 KiB | ||||
67 | Accepted | 64ms | 92360 KiB | ||||
68 | Accepted | 71ms | 91992 KiB | ||||
69 | Accepted | 64ms | 91796 KiB | ||||
70 | Accepted | 71ms | 92112 KiB | ||||
71 | Accepted | 70ms | 92048 KiB | ||||
72 | Accepted | 64ms | 92796 KiB | ||||
73 | Accepted | 64ms | 92072 KiB | ||||
74 | Accepted | 63ms | 91948 KiB | ||||
75 | Accepted | 70ms | 92236 KiB | ||||
76 | Accepted | 68ms | 92080 KiB | ||||
77 | Accepted | 65ms | 92356 KiB | ||||
78 | Accepted | 65ms | 92168 KiB | ||||
79 | Accepted | 64ms | 92100 KiB | ||||
80 | Accepted | 286ms | 181116 KiB | ||||
81 | Accepted | 349ms | 183860 KiB | ||||
82 | Accepted | 384ms | 183568 KiB | ||||
83 | Accepted | 337ms | 184100 KiB | ||||
84 | Accepted | 303ms | 183348 KiB | ||||
85 | Accepted | 248ms | 183224 KiB | ||||
86 | Accepted | 224ms | 182192 KiB | ||||
87 | Accepted | 236ms | 186124 KiB | ||||
88 | Accepted | 222ms | 183196 KiB | ||||
89 | Accepted | 360ms | 200000 KiB | ||||
90 | Accepted | 397ms | 199280 KiB | ||||
91 | Accepted | 414ms | 231340 KiB | ||||
92 | Accepted | 433ms | 241200 KiB | ||||
93 | Time limit exceeded | 1.07s | 93968 KiB | ||||
94 | Time limit exceeded | 1.07s | 90336 KiB | ||||
95 | Accepted | 275ms | 187528 KiB | ||||
96 | Accepted | 393ms | 218468 KiB | ||||
97 | Accepted | 272ms | 185748 KiB | ||||
98 | Accepted | 248ms | 180908 KiB | ||||
99 | Accepted | 257ms | 179756 KiB | ||||
100 | Accepted | 273ms | 179628 KiB | ||||
101 | Accepted | 280ms | 185312 KiB |