10945 | 2024-04-20 18:04:50 | 42 | Vállalati ügyelet | pypy3 | Runtime error 22/100 | 1.088s | 301580 KiB |
from sys import stdin, stdout
input=stdin.readline
def main():
N = int(input())
P = [0]+list(map(int, input().split()))
A = [set()]+[{int(x)} for x in input().split()]
res=[1]*(N+1)
for i in range(N,0,-1):
while res[i] in A[i]:
A[i].remove(res[i])
res[i]+=1
res[P[i]]=max(res[i],res[P[i]])
if len(A[P[i]]) >= len(A[i]):
A[P[i]]=A[P[i]].union(A.pop())
else:
A[P[i]]=A.pop().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 | 39ms | 76288 KiB | ||||
2 | Accepted | 460ms | 236832 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 39ms | 76988 KiB | ||||
4 | Accepted | 39ms | 77124 KiB | ||||
5 | Accepted | 39ms | 76868 KiB | ||||
6 | Accepted | 39ms | 77428 KiB | ||||
subtask3 | 0/8 | ||||||
7 | Accepted | 39ms | 76988 KiB | ||||
8 | Accepted | 39ms | 77124 KiB | ||||
9 | Accepted | 39ms | 76868 KiB | ||||
10 | Accepted | 39ms | 77428 KiB | ||||
11 | Runtime error | 787ms | 301580 KiB | ||||
12 | Runtime error | 911ms | 301564 KiB | ||||
13 | Time limit exceeded | 1.088s | 130504 KiB | ||||
14 | Runtime error | 514ms | 301152 KiB | ||||
subtask4 | 0/12 | ||||||
15 | Accepted | 39ms | 76988 KiB | ||||
16 | Accepted | 39ms | 77124 KiB | ||||
17 | Accepted | 39ms | 76868 KiB | ||||
18 | Accepted | 39ms | 77428 KiB | ||||
19 | Runtime error | 759ms | 300752 KiB | ||||
20 | Runtime error | 887ms | 300536 KiB | ||||
21 | Time limit exceeded | 1.024s | 127456 KiB | ||||
22 | Runtime error | 532ms | 300148 KiB | ||||
23 | Accepted | 337ms | 231352 KiB | ||||
24 | Runtime error | 746ms | 299864 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 39ms | 76988 KiB | ||||
26 | Accepted | 39ms | 77124 KiB | ||||
27 | Accepted | 39ms | 76868 KiB | ||||
28 | Accepted | 39ms | 77428 KiB | ||||
29 | Accepted | 78ms | 93616 KiB | ||||
30 | Accepted | 74ms | 92908 KiB | ||||
31 | Accepted | 64ms | 92276 KiB | ||||
32 | Accepted | 65ms | 92360 KiB | ||||
33 | Accepted | 71ms | 92692 KiB | ||||
34 | Accepted | 74ms | 91980 KiB | ||||
35 | Accepted | 68ms | 92296 KiB | ||||
36 | Accepted | 68ms | 92584 KiB | ||||
37 | Accepted | 79ms | 92644 KiB | ||||
38 | Accepted | 76ms | 92792 KiB | ||||
39 | Accepted | 79ms | 94096 KiB | ||||
40 | Accepted | 74ms | 93280 KiB | ||||
41 | Accepted | 70ms | 92500 KiB | ||||
subtask6 | 0/28 | ||||||
42 | Accepted | 517ms | 268680 KiB | ||||
43 | Accepted | 754ms | 274036 KiB | ||||
44 | Time limit exceeded | 1.08s | 119984 KiB | ||||
45 | Time limit exceeded | 1.064s | 120244 KiB | ||||
46 | Time limit exceeded | 1.072s | 119424 KiB | ||||
47 | Time limit exceeded | 1.042s | 111912 KiB | ||||
48 | Runtime error | 560ms | 298544 KiB | ||||
49 | Runtime error | 529ms | 298604 KiB | ||||
50 | Accepted | 379ms | 233564 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 39ms | 80800 KiB | ||||
52 | Accepted | 472ms | 240840 KiB | ||||
53 | Accepted | 39ms | 76988 KiB | ||||
54 | Accepted | 39ms | 77124 KiB | ||||
55 | Accepted | 39ms | 76868 KiB | ||||
56 | Accepted | 39ms | 77428 KiB | ||||
57 | Runtime error | 787ms | 301580 KiB | ||||
58 | Runtime error | 911ms | 301564 KiB | ||||
59 | Time limit exceeded | 1.088s | 130504 KiB | ||||
60 | Runtime error | 514ms | 301152 KiB | ||||
61 | Runtime error | 759ms | 300752 KiB | ||||
62 | Runtime error | 887ms | 300536 KiB | ||||
63 | Time limit exceeded | 1.024s | 127456 KiB | ||||
64 | Runtime error | 532ms | 300148 KiB | ||||
65 | Accepted | 337ms | 231352 KiB | ||||
66 | Runtime error | 746ms | 299864 KiB | ||||
67 | Accepted | 78ms | 93616 KiB | ||||
68 | Accepted | 74ms | 92908 KiB | ||||
69 | Accepted | 64ms | 92276 KiB | ||||
70 | Accepted | 65ms | 92360 KiB | ||||
71 | Accepted | 71ms | 92692 KiB | ||||
72 | Accepted | 74ms | 91980 KiB | ||||
73 | Accepted | 68ms | 92296 KiB | ||||
74 | Accepted | 68ms | 92584 KiB | ||||
75 | Accepted | 79ms | 92644 KiB | ||||
76 | Accepted | 76ms | 92792 KiB | ||||
77 | Accepted | 79ms | 94096 KiB | ||||
78 | Accepted | 74ms | 93280 KiB | ||||
79 | Accepted | 70ms | 92500 KiB | ||||
80 | Accepted | 517ms | 268680 KiB | ||||
81 | Accepted | 754ms | 274036 KiB | ||||
82 | Time limit exceeded | 1.08s | 119984 KiB | ||||
83 | Time limit exceeded | 1.064s | 120244 KiB | ||||
84 | Time limit exceeded | 1.072s | 119424 KiB | ||||
85 | Time limit exceeded | 1.042s | 111912 KiB | ||||
86 | Runtime error | 560ms | 298544 KiB | ||||
87 | Runtime error | 529ms | 298604 KiB | ||||
88 | Accepted | 379ms | 233564 KiB | ||||
89 | Runtime error | 602ms | 298612 KiB | ||||
90 | Runtime error | 578ms | 298592 KiB | ||||
91 | Runtime error | 485ms | 298516 KiB | ||||
92 | Runtime error | 501ms | 298464 KiB | ||||
93 | Time limit exceeded | 1.085s | 119208 KiB | ||||
94 | Runtime error | 563ms | 298528 KiB | ||||
95 | Runtime error | 518ms | 298480 KiB | ||||
96 | Runtime error | 610ms | 298332 KiB | ||||
97 | Accepted | 619ms | 255716 KiB | ||||
98 | Accepted | 490ms | 232016 KiB | ||||
99 | Accepted | 435ms | 233200 KiB | ||||
100 | Accepted | 638ms | 247652 KiB | ||||
101 | Accepted | 578ms | 235252 KiB |