10950 | 2024-04-20 18:29:22 | 42 | Vállalati ügyelet | pypy3 | Time limit exceeded 70/100 | 1.082s | 259504 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:
A[P[i]] |= cur
#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 | 43ms | 76412 KiB | ||||
2 | Accepted | 335ms | 183160 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 43ms | 77080 KiB | ||||
4 | Accepted | 39ms | 77516 KiB | ||||
5 | Accepted | 39ms | 77432 KiB | ||||
6 | Accepted | 39ms | 77776 KiB | ||||
subtask3 | 8/8 | ||||||
7 | Accepted | 43ms | 77080 KiB | ||||
8 | Accepted | 39ms | 77516 KiB | ||||
9 | Accepted | 39ms | 77432 KiB | ||||
10 | Accepted | 39ms | 77776 KiB | ||||
11 | Accepted | 179ms | 177640 KiB | ||||
12 | Accepted | 180ms | 173032 KiB | ||||
13 | Accepted | 185ms | 177664 KiB | ||||
14 | Accepted | 216ms | 186456 KiB | ||||
subtask4 | 12/12 | ||||||
15 | Accepted | 43ms | 77080 KiB | ||||
16 | Accepted | 39ms | 77516 KiB | ||||
17 | Accepted | 39ms | 77432 KiB | ||||
18 | Accepted | 39ms | 77776 KiB | ||||
19 | Accepted | 172ms | 182928 KiB | ||||
20 | Accepted | 173ms | 177848 KiB | ||||
21 | Accepted | 173ms | 179012 KiB | ||||
22 | Accepted | 202ms | 186264 KiB | ||||
23 | Accepted | 193ms | 178724 KiB | ||||
24 | Accepted | 189ms | 180304 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 43ms | 77080 KiB | ||||
26 | Accepted | 39ms | 77516 KiB | ||||
27 | Accepted | 39ms | 77432 KiB | ||||
28 | Accepted | 39ms | 77776 KiB | ||||
29 | Accepted | 61ms | 90552 KiB | ||||
30 | Accepted | 68ms | 91180 KiB | ||||
31 | Accepted | 64ms | 90400 KiB | ||||
32 | Accepted | 71ms | 90900 KiB | ||||
33 | Accepted | 68ms | 91312 KiB | ||||
34 | Accepted | 63ms | 92100 KiB | ||||
35 | Accepted | 64ms | 91808 KiB | ||||
36 | Accepted | 63ms | 91808 KiB | ||||
37 | Accepted | 75ms | 91976 KiB | ||||
38 | Accepted | 67ms | 91644 KiB | ||||
39 | Accepted | 72ms | 91884 KiB | ||||
40 | Accepted | 72ms | 92068 KiB | ||||
41 | Accepted | 67ms | 92168 KiB | ||||
subtask6 | 28/28 | ||||||
42 | Accepted | 323ms | 180636 KiB | ||||
43 | Accepted | 514ms | 183800 KiB | ||||
44 | Accepted | 657ms | 183892 KiB | ||||
45 | Accepted | 505ms | 180660 KiB | ||||
46 | Accepted | 368ms | 182776 KiB | ||||
47 | Accepted | 234ms | 180568 KiB | ||||
48 | Accepted | 216ms | 182260 KiB | ||||
49 | Accepted | 203ms | 188080 KiB | ||||
50 | Accepted | 194ms | 180736 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 39ms | 80004 KiB | ||||
52 | Accepted | 337ms | 186204 KiB | ||||
53 | Accepted | 43ms | 77080 KiB | ||||
54 | Accepted | 39ms | 77516 KiB | ||||
55 | Accepted | 39ms | 77432 KiB | ||||
56 | Accepted | 39ms | 77776 KiB | ||||
57 | Accepted | 179ms | 177640 KiB | ||||
58 | Accepted | 180ms | 173032 KiB | ||||
59 | Accepted | 185ms | 177664 KiB | ||||
60 | Accepted | 216ms | 186456 KiB | ||||
61 | Accepted | 172ms | 182928 KiB | ||||
62 | Accepted | 173ms | 177848 KiB | ||||
63 | Accepted | 173ms | 179012 KiB | ||||
64 | Accepted | 202ms | 186264 KiB | ||||
65 | Accepted | 193ms | 178724 KiB | ||||
66 | Accepted | 189ms | 180304 KiB | ||||
67 | Accepted | 61ms | 90552 KiB | ||||
68 | Accepted | 68ms | 91180 KiB | ||||
69 | Accepted | 64ms | 90400 KiB | ||||
70 | Accepted | 71ms | 90900 KiB | ||||
71 | Accepted | 68ms | 91312 KiB | ||||
72 | Accepted | 63ms | 92100 KiB | ||||
73 | Accepted | 64ms | 91808 KiB | ||||
74 | Accepted | 63ms | 91808 KiB | ||||
75 | Accepted | 75ms | 91976 KiB | ||||
76 | Accepted | 67ms | 91644 KiB | ||||
77 | Accepted | 72ms | 91884 KiB | ||||
78 | Accepted | 72ms | 92068 KiB | ||||
79 | Accepted | 67ms | 92168 KiB | ||||
80 | Accepted | 323ms | 180636 KiB | ||||
81 | Accepted | 514ms | 183800 KiB | ||||
82 | Accepted | 657ms | 183892 KiB | ||||
83 | Accepted | 505ms | 180660 KiB | ||||
84 | Accepted | 368ms | 182776 KiB | ||||
85 | Accepted | 234ms | 180568 KiB | ||||
86 | Accepted | 216ms | 182260 KiB | ||||
87 | Accepted | 203ms | 188080 KiB | ||||
88 | Accepted | 194ms | 180736 KiB | ||||
89 | Accepted | 418ms | 199096 KiB | ||||
90 | Accepted | 423ms | 203056 KiB | ||||
91 | Accepted | 503ms | 234556 KiB | ||||
92 | Accepted | 460ms | 259504 KiB | ||||
93 | Time limit exceeded | 1.082s | 82152 KiB | ||||
94 | Time limit exceeded | 1.065s | 83296 KiB | ||||
95 | Accepted | 246ms | 183724 KiB | ||||
96 | Accepted | 750ms | 190448 KiB | ||||
97 | Accepted | 375ms | 185764 KiB | ||||
98 | Accepted | 279ms | 181504 KiB | ||||
99 | Accepted | 307ms | 180184 KiB | ||||
100 | Accepted | 333ms | 186360 KiB | ||||
101 | Accepted | 286ms | 185896 KiB |