10946 | 2024-04-20 18:05:00 | 42 | Vállalati ügyelet | python3 | Time limit exceeded 22/100 | 1.105s | 179428 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 | 18ms | 11372 KiB | ||||
2 | Accepted | 984ms | 162464 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 17ms | 12004 KiB | ||||
4 | Accepted | 17ms | 12148 KiB | ||||
5 | Accepted | 17ms | 12116 KiB | ||||
6 | Accepted | 17ms | 12008 KiB | ||||
subtask3 | 0/8 | ||||||
7 | Accepted | 17ms | 12004 KiB | ||||
8 | Accepted | 17ms | 12148 KiB | ||||
9 | Accepted | 17ms | 12116 KiB | ||||
10 | Accepted | 17ms | 12008 KiB | ||||
11 | Time limit exceeded | 1.103s | 74532 KiB | ||||
12 | Time limit exceeded | 1.105s | 75260 KiB | ||||
13 | Time limit exceeded | 1.067s | 73680 KiB | ||||
14 | Time limit exceeded | 1.075s | 74140 KiB | ||||
subtask4 | 0/12 | ||||||
15 | Accepted | 17ms | 12004 KiB | ||||
16 | Accepted | 17ms | 12148 KiB | ||||
17 | Accepted | 17ms | 12116 KiB | ||||
18 | Accepted | 17ms | 12008 KiB | ||||
19 | Time limit exceeded | 1.07s | 81640 KiB | ||||
20 | Time limit exceeded | 1.064s | 81780 KiB | ||||
21 | Time limit exceeded | 1.08s | 81872 KiB | ||||
22 | Time limit exceeded | 1.072s | 82368 KiB | ||||
23 | Accepted | 758ms | 166532 KiB | ||||
24 | Time limit exceeded | 1.057s | 82312 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 17ms | 12004 KiB | ||||
26 | Accepted | 17ms | 12148 KiB | ||||
27 | Accepted | 17ms | 12116 KiB | ||||
28 | Accepted | 17ms | 12008 KiB | ||||
29 | Accepted | 48ms | 14904 KiB | ||||
30 | Accepted | 48ms | 15264 KiB | ||||
31 | Accepted | 25ms | 14464 KiB | ||||
32 | Accepted | 25ms | 14692 KiB | ||||
33 | Accepted | 25ms | 14776 KiB | ||||
34 | Accepted | 24ms | 14472 KiB | ||||
35 | Accepted | 26ms | 15288 KiB | ||||
36 | Accepted | 26ms | 14860 KiB | ||||
37 | Accepted | 39ms | 15236 KiB | ||||
38 | Accepted | 24ms | 14928 KiB | ||||
39 | Accepted | 24ms | 14688 KiB | ||||
40 | Accepted | 25ms | 14872 KiB | ||||
41 | Accepted | 25ms | 15140 KiB | ||||
subtask6 | 0/28 | ||||||
42 | Time limit exceeded | 1.013s | 166968 KiB | ||||
43 | Time limit exceeded | 1.105s | 82952 KiB | ||||
44 | Time limit exceeded | 1.065s | 83028 KiB | ||||
45 | Time limit exceeded | 1.065s | 83260 KiB | ||||
46 | Time limit exceeded | 1.065s | 83340 KiB | ||||
47 | Time limit exceeded | 1.105s | 83332 KiB | ||||
48 | Time limit exceeded | 1.062s | 75632 KiB | ||||
49 | Time limit exceeded | 1.08s | 83620 KiB | ||||
50 | Accepted | 805ms | 168132 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 18ms | 14604 KiB | ||||
52 | Accepted | 1s | 165216 KiB | ||||
53 | Accepted | 17ms | 12004 KiB | ||||
54 | Accepted | 17ms | 12148 KiB | ||||
55 | Accepted | 17ms | 12116 KiB | ||||
56 | Accepted | 17ms | 12008 KiB | ||||
57 | Time limit exceeded | 1.103s | 74532 KiB | ||||
58 | Time limit exceeded | 1.105s | 75260 KiB | ||||
59 | Time limit exceeded | 1.067s | 73680 KiB | ||||
60 | Time limit exceeded | 1.075s | 74140 KiB | ||||
61 | Time limit exceeded | 1.07s | 81640 KiB | ||||
62 | Time limit exceeded | 1.064s | 81780 KiB | ||||
63 | Time limit exceeded | 1.08s | 81872 KiB | ||||
64 | Time limit exceeded | 1.072s | 82368 KiB | ||||
65 | Accepted | 758ms | 166532 KiB | ||||
66 | Time limit exceeded | 1.057s | 82312 KiB | ||||
67 | Accepted | 48ms | 14904 KiB | ||||
68 | Accepted | 48ms | 15264 KiB | ||||
69 | Accepted | 25ms | 14464 KiB | ||||
70 | Accepted | 25ms | 14692 KiB | ||||
71 | Accepted | 25ms | 14776 KiB | ||||
72 | Accepted | 24ms | 14472 KiB | ||||
73 | Accepted | 26ms | 15288 KiB | ||||
74 | Accepted | 26ms | 14860 KiB | ||||
75 | Accepted | 39ms | 15236 KiB | ||||
76 | Accepted | 24ms | 14928 KiB | ||||
77 | Accepted | 24ms | 14688 KiB | ||||
78 | Accepted | 25ms | 14872 KiB | ||||
79 | Accepted | 25ms | 15140 KiB | ||||
80 | Time limit exceeded | 1.013s | 166968 KiB | ||||
81 | Time limit exceeded | 1.105s | 82952 KiB | ||||
82 | Time limit exceeded | 1.065s | 83028 KiB | ||||
83 | Time limit exceeded | 1.065s | 83260 KiB | ||||
84 | Time limit exceeded | 1.065s | 83340 KiB | ||||
85 | Time limit exceeded | 1.105s | 83332 KiB | ||||
86 | Time limit exceeded | 1.062s | 75632 KiB | ||||
87 | Time limit exceeded | 1.08s | 83620 KiB | ||||
88 | Accepted | 805ms | 168132 KiB | ||||
89 | Accepted | 783ms | 153144 KiB | ||||
90 | Accepted | 954ms | 160016 KiB | ||||
91 | Accepted | 995ms | 179428 KiB | ||||
92 | Time limit exceeded | 1.067s | 98548 KiB | ||||
93 | Time limit exceeded | 1.085s | 74136 KiB | ||||
94 | Time limit exceeded | 1.065s | 79244 KiB | ||||
95 | Time limit exceeded | 1.075s | 84288 KiB | ||||
96 | Time limit exceeded | 1.07s | 83608 KiB | ||||
97 | Time limit exceeded | 1.065s | 82376 KiB | ||||
98 | Accepted | 898ms | 156120 KiB | ||||
99 | Accepted | 943ms | 167636 KiB | ||||
100 | Time limit exceeded | 1.065s | 82888 KiB | ||||
101 | Time limit exceeded | 1.047s | 79840 KiB |