10942 | 2024-04-20 17:56:05 | 42 | Vállalati ügyelet | python3 | Time limit exceeded 22/100 | 1.105s | 167708 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]])
#print(A)
#print(A)
print(*res[1:])
#stdout.write(''.join(A))
#stdout.write('\n')
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 10968 KiB | ||||
2 | Accepted | 915ms | 162440 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 18ms | 11700 KiB | ||||
4 | Accepted | 17ms | 12164 KiB | ||||
5 | Accepted | 17ms | 11856 KiB | ||||
6 | Accepted | 17ms | 11856 KiB | ||||
subtask3 | 0/8 | ||||||
7 | Accepted | 18ms | 11700 KiB | ||||
8 | Accepted | 17ms | 12164 KiB | ||||
9 | Accepted | 17ms | 11856 KiB | ||||
10 | Accepted | 17ms | 11856 KiB | ||||
11 | Time limit exceeded | 1.103s | 74436 KiB | ||||
12 | Time limit exceeded | 1.032s | 75080 KiB | ||||
13 | Time limit exceeded | 1.059s | 73716 KiB | ||||
14 | Time limit exceeded | 1.064s | 74324 KiB | ||||
subtask4 | 0/12 | ||||||
15 | Accepted | 18ms | 11700 KiB | ||||
16 | Accepted | 17ms | 12164 KiB | ||||
17 | Accepted | 17ms | 11856 KiB | ||||
18 | Accepted | 17ms | 11856 KiB | ||||
19 | Time limit exceeded | 1.075s | 82024 KiB | ||||
20 | Time limit exceeded | 1.075s | 82144 KiB | ||||
21 | Time limit exceeded | 1.072s | 82472 KiB | ||||
22 | Time limit exceeded | 1.059s | 82728 KiB | ||||
23 | Accepted | 736ms | 166844 KiB | ||||
24 | Time limit exceeded | 1.046s | 82496 KiB | ||||
subtask5 | 17/17 | ||||||
25 | Accepted | 18ms | 11700 KiB | ||||
26 | Accepted | 17ms | 12164 KiB | ||||
27 | Accepted | 17ms | 11856 KiB | ||||
28 | Accepted | 17ms | 11856 KiB | ||||
29 | Accepted | 46ms | 15084 KiB | ||||
30 | Accepted | 48ms | 15424 KiB | ||||
31 | Accepted | 24ms | 15456 KiB | ||||
32 | Accepted | 24ms | 14872 KiB | ||||
33 | Accepted | 24ms | 14996 KiB | ||||
34 | Accepted | 23ms | 14860 KiB | ||||
35 | Accepted | 25ms | 15204 KiB | ||||
36 | Accepted | 25ms | 14872 KiB | ||||
37 | Accepted | 37ms | 15364 KiB | ||||
38 | Accepted | 23ms | 15076 KiB | ||||
39 | Accepted | 23ms | 14980 KiB | ||||
40 | Accepted | 24ms | 15252 KiB | ||||
41 | Accepted | 23ms | 14988 KiB | ||||
subtask6 | 0/28 | ||||||
42 | Accepted | 992ms | 166984 KiB | ||||
43 | Time limit exceeded | 1.067s | 82836 KiB | ||||
44 | Time limit exceeded | 1.065s | 83136 KiB | ||||
45 | Time limit exceeded | 1.052s | 83060 KiB | ||||
46 | Time limit exceeded | 1.042s | 83420 KiB | ||||
47 | Time limit exceeded | 1.072s | 83348 KiB | ||||
48 | Time limit exceeded | 1.07s | 75528 KiB | ||||
49 | Time limit exceeded | 1.105s | 83452 KiB | ||||
50 | Accepted | 731ms | 167580 KiB | ||||
subtask7 | 0/30 | ||||||
51 | Accepted | 17ms | 14276 KiB | ||||
52 | Time limit exceeded | 1.006s | 165088 KiB | ||||
53 | Accepted | 18ms | 11700 KiB | ||||
54 | Accepted | 17ms | 12164 KiB | ||||
55 | Accepted | 17ms | 11856 KiB | ||||
56 | Accepted | 17ms | 11856 KiB | ||||
57 | Time limit exceeded | 1.103s | 74436 KiB | ||||
58 | Time limit exceeded | 1.032s | 75080 KiB | ||||
59 | Time limit exceeded | 1.059s | 73716 KiB | ||||
60 | Time limit exceeded | 1.064s | 74324 KiB | ||||
61 | Time limit exceeded | 1.075s | 82024 KiB | ||||
62 | Time limit exceeded | 1.075s | 82144 KiB | ||||
63 | Time limit exceeded | 1.072s | 82472 KiB | ||||
64 | Time limit exceeded | 1.059s | 82728 KiB | ||||
65 | Accepted | 736ms | 166844 KiB | ||||
66 | Time limit exceeded | 1.046s | 82496 KiB | ||||
67 | Accepted | 46ms | 15084 KiB | ||||
68 | Accepted | 48ms | 15424 KiB | ||||
69 | Accepted | 24ms | 15456 KiB | ||||
70 | Accepted | 24ms | 14872 KiB | ||||
71 | Accepted | 24ms | 14996 KiB | ||||
72 | Accepted | 23ms | 14860 KiB | ||||
73 | Accepted | 25ms | 15204 KiB | ||||
74 | Accepted | 25ms | 14872 KiB | ||||
75 | Accepted | 37ms | 15364 KiB | ||||
76 | Accepted | 23ms | 15076 KiB | ||||
77 | Accepted | 23ms | 14980 KiB | ||||
78 | Accepted | 24ms | 15252 KiB | ||||
79 | Accepted | 23ms | 14988 KiB | ||||
80 | Accepted | 992ms | 166984 KiB | ||||
81 | Time limit exceeded | 1.067s | 82836 KiB | ||||
82 | Time limit exceeded | 1.065s | 83136 KiB | ||||
83 | Time limit exceeded | 1.052s | 83060 KiB | ||||
84 | Time limit exceeded | 1.042s | 83420 KiB | ||||
85 | Time limit exceeded | 1.072s | 83348 KiB | ||||
86 | Time limit exceeded | 1.07s | 75528 KiB | ||||
87 | Time limit exceeded | 1.105s | 83452 KiB | ||||
88 | Accepted | 731ms | 167580 KiB | ||||
89 | Accepted | 889ms | 152588 KiB | ||||
90 | Accepted | 808ms | 159860 KiB | ||||
91 | Time limit exceeded | 1.085s | 91628 KiB | ||||
92 | Time limit exceeded | 1.082s | 98120 KiB | ||||
93 | Time limit exceeded | 1.077s | 74044 KiB | ||||
94 | Time limit exceeded | 1.044s | 79192 KiB | ||||
95 | Time limit exceeded | 1.093s | 84064 KiB | ||||
96 | Time limit exceeded | 1.085s | 83620 KiB | ||||
97 | Time limit exceeded | 1.064s | 82492 KiB | ||||
98 | Accepted | 841ms | 156036 KiB | ||||
99 | Accepted | 943ms | 167708 KiB | ||||
100 | Time limit exceeded | 1.065s | 82692 KiB | ||||
101 | Time limit exceeded | 1.062s | 79844 KiB |