10948 | 2024-04-20 18:16:37 | 42 | Vállalati ügyelet | pypy3 | Time limit exceeded 34/100 | 1.093s | 247648 KiB |
from sys import stdin, stdout
input=stdin.readline
def main():
N = int(input())
P = [0]+list(map(int, input().split()))
A = [0]+[int(x) for x in 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)
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 | 46ms | 76732 KiB | ||||
2 | Accepted | 308ms | 172080 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 46ms | 77284 KiB | ||||
4 | Accepted | 43ms | 77356 KiB | ||||
5 | Accepted | 48ms | 78180 KiB | ||||
6 | Accepted | 43ms | 77392 KiB | ||||
subtask3 | 0/8 | ||||||
7 | Accepted | 46ms | 77284 KiB | ||||
8 | Accepted | 43ms | 77356 KiB | ||||
9 | Accepted | 48ms | 78180 KiB | ||||
10 | Accepted | 43ms | 77392 KiB | ||||
11 | Time limit exceeded | 1.082s | 78104 KiB | ||||
12 | Time limit exceeded | 1.093s | 79524 KiB | ||||
13 | Time limit exceeded | 1.044s | 77472 KiB | ||||
14 | Time limit exceeded | 1.06s | 78180 KiB | ||||
subtask4 | 12/12 | ||||||
15 | Accepted | 46ms | 77284 KiB | ||||
16 | Accepted | 43ms | 77356 KiB | ||||
17 | Accepted | 48ms | 78180 KiB | ||||
18 | Accepted | 43ms | 77392 KiB | ||||
19 | Accepted | 194ms | 164148 KiB | ||||
20 | Accepted | 202ms | 163548 KiB | ||||
21 | Accepted | 195ms | 165816 KiB | ||||
22 | Accepted | 243ms | 195240 KiB | ||||
23 | Accepted | 215ms | 166976 KiB | ||||
24 | Accepted | 189ms | 172772 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 46ms | 77284 KiB | ||||
26 | Accepted | 43ms | 77356 KiB | ||||
27 | Accepted | 48ms | 78180 KiB | ||||
28 | Accepted | 43ms | 77392 KiB | ||||
29 | Accepted | 86ms | 92836 KiB | ||||
30 | Accepted | 72ms | 90968 KiB | ||||
31 | Accepted | 71ms | 91008 KiB | ||||
32 | Accepted | 75ms | 92000 KiB | ||||
33 | Accepted | 76ms | 91952 KiB | ||||
34 | Accepted | 70ms | 92016 KiB | ||||
35 | Accepted | 75ms | 92416 KiB | ||||
36 | Accepted | 74ms | 91856 KiB | ||||
37 | Accepted | 78ms | 92264 KiB | ||||
38 | Accepted | 70ms | 91780 KiB | ||||
39 | Accepted | 75ms | 92388 KiB | ||||
40 | Accepted | 75ms | 92108 KiB | ||||
41 | Accepted | 74ms | 92132 KiB | ||||
subtask6 | 0/28 | ||||||
42 | Accepted | 365ms | 180728 KiB | ||||
43 | Accepted | 532ms | 179596 KiB | ||||
44 | Accepted | 680ms | 180260 KiB | ||||
45 | Accepted | 605ms | 180288 KiB | ||||
46 | Accepted | 423ms | 178740 KiB | ||||
47 | Accepted | 254ms | 168216 KiB | ||||
48 | Time limit exceeded | 1.077s | 80236 KiB | ||||
49 | Accepted | 202ms | 196060 KiB | ||||
50 | Accepted | 193ms | 168440 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 41ms | 80636 KiB | ||||
52 | Accepted | 305ms | 175880 KiB | ||||
53 | Accepted | 46ms | 77284 KiB | ||||
54 | Accepted | 43ms | 77356 KiB | ||||
55 | Accepted | 48ms | 78180 KiB | ||||
56 | Accepted | 43ms | 77392 KiB | ||||
57 | Time limit exceeded | 1.082s | 78104 KiB | ||||
58 | Time limit exceeded | 1.093s | 79524 KiB | ||||
59 | Time limit exceeded | 1.044s | 77472 KiB | ||||
60 | Time limit exceeded | 1.06s | 78180 KiB | ||||
61 | Accepted | 194ms | 164148 KiB | ||||
62 | Accepted | 202ms | 163548 KiB | ||||
63 | Accepted | 195ms | 165816 KiB | ||||
64 | Accepted | 243ms | 195240 KiB | ||||
65 | Accepted | 215ms | 166976 KiB | ||||
66 | Accepted | 189ms | 172772 KiB | ||||
67 | Accepted | 86ms | 92836 KiB | ||||
68 | Accepted | 72ms | 90968 KiB | ||||
69 | Accepted | 71ms | 91008 KiB | ||||
70 | Accepted | 75ms | 92000 KiB | ||||
71 | Accepted | 76ms | 91952 KiB | ||||
72 | Accepted | 70ms | 92016 KiB | ||||
73 | Accepted | 75ms | 92416 KiB | ||||
74 | Accepted | 74ms | 91856 KiB | ||||
75 | Accepted | 78ms | 92264 KiB | ||||
76 | Accepted | 70ms | 91780 KiB | ||||
77 | Accepted | 75ms | 92388 KiB | ||||
78 | Accepted | 75ms | 92108 KiB | ||||
79 | Accepted | 74ms | 92132 KiB | ||||
80 | Accepted | 365ms | 180728 KiB | ||||
81 | Accepted | 532ms | 179596 KiB | ||||
82 | Accepted | 680ms | 180260 KiB | ||||
83 | Accepted | 605ms | 180288 KiB | ||||
84 | Accepted | 423ms | 178740 KiB | ||||
85 | Accepted | 254ms | 168216 KiB | ||||
86 | Time limit exceeded | 1.077s | 80236 KiB | ||||
87 | Accepted | 202ms | 196060 KiB | ||||
88 | Accepted | 193ms | 168440 KiB | ||||
89 | Accepted | 393ms | 212072 KiB | ||||
90 | Accepted | 495ms | 221820 KiB | ||||
91 | Accepted | 458ms | 229428 KiB | ||||
92 | Accepted | 595ms | 247648 KiB | ||||
93 | Time limit exceeded | 1.042s | 94648 KiB | ||||
94 | Time limit exceeded | 1.057s | 89288 KiB | ||||
95 | Accepted | 280ms | 210736 KiB | ||||
96 | Accepted | 717ms | 218296 KiB | ||||
97 | Accepted | 358ms | 178884 KiB | ||||
98 | Accepted | 289ms | 162528 KiB | ||||
99 | Accepted | 317ms | 168136 KiB | ||||
100 | Accepted | 389ms | 174204 KiB | ||||
101 | Accepted | 277ms | 166172 KiB |