Task: | Chain Reaction |
Sender: | ilyas.ben |
Submission time: | 2024-11-25 17:10:36 +0200 |
Language: | Python2 (PyPy2) |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | RUNTIME ERROR | 0.03 s | details |
#2 | RUNTIME ERROR | 0.03 s | details |
#3 | RUNTIME ERROR | 0.03 s | details |
#4 | RUNTIME ERROR | 0.03 s | details |
#5 | RUNTIME ERROR | 0.03 s | details |
#6 | RUNTIME ERROR | 0.03 s | details |
#7 | RUNTIME ERROR | 0.03 s | details |
#8 | RUNTIME ERROR | 0.04 s | details |
#9 | RUNTIME ERROR | 0.03 s | details |
#10 | RUNTIME ERROR | 0.03 s | details |
#11 | RUNTIME ERROR | 0.03 s | details |
#12 | RUNTIME ERROR | 0.04 s | details |
#13 | RUNTIME ERROR | 0.03 s | details |
#14 | RUNTIME ERROR | 0.03 s | details |
#15 | RUNTIME ERROR | 0.04 s | details |
#16 | RUNTIME ERROR | 0.03 s | details |
#17 | RUNTIME ERROR | 0.03 s | details |
#18 | RUNTIME ERROR | 0.03 s | details |
#19 | RUNTIME ERROR | 0.04 s | details |
#20 | RUNTIME ERROR | 0.03 s | details |
#21 | RUNTIME ERROR | 0.04 s | details |
#22 | RUNTIME ERROR | 0.03 s | details |
#23 | RUNTIME ERROR | 0.03 s | details |
#24 | RUNTIME ERROR | 0.03 s | details |
#25 | RUNTIME ERROR | 0.03 s | details |
#26 | RUNTIME ERROR | 0.03 s | details |
#27 | RUNTIME ERROR | 0.03 s | details |
#28 | RUNTIME ERROR | 0.03 s | details |
#29 | RUNTIME ERROR | 0.03 s | details |
#30 | RUNTIME ERROR | 0.03 s | details |
#31 | RUNTIME ERROR | 0.03 s | details |
#32 | RUNTIME ERROR | 0.03 s | details |
Code
from collections import defaultdict import sys sys.setrecursionlimit(10**6) def max_charge(n, s, a, b, edges): s -= 1 adj = defaultdict(list) for u, v in edges: adj[u - 1].append(v - 1) adj[v - 1].append(u - 1) visited = [False] * n max_charge = 1 def dfs(node, current_charge): nonlocal max_charge visited[node] = True max_charge = max(max_charge, current_charge) for neighbor in adj[node]: if not visited[neighbor]: new_charge_1 = current_charge + (a[neighbor] - a[node]) new_charge_2 = current_charge + (b[neighbor] - b[node]) dfs(neighbor, new_charge_1) dfs(neighbor, new_charge_2) dfs(s, 1) return max_charge n, s = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) edges = [tuple(map(int, input().split())) for _ in range(n - 1)] print(max_charge(n, s, a, b, edges))
Test details
Test 1
Verdict: RUNTIME ERROR
input |
---|
5 1
4 2 1 1 1 5 2 1 5 4 1 2 1 3 ... |
correct output |
---|
2 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 2
Verdict: RUNTIME ERROR
input |
---|
4 1
4 2 2 1 1 1 1 1 1 2 2 3 ... |
correct output |
---|
1 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 3
Verdict: RUNTIME ERROR
input |
---|
10 8
7 2 10 4 5 9 1 2 3 1 9 8 6 6 4 6 10 1 7 8 4 5 10 3 ... |
correct output |
---|
19 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 4
Verdict: RUNTIME ERROR
input |
---|
10 1
8 8 6 8 1 9 2 2 7 7 9 6 5 9 2 5 6 5 5 8 1 6 6 7 ... |
correct output |
---|
9 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 5
Verdict: RUNTIME ERROR
input |
---|
10 1
4 1 4 1 4 6 1 1 4 5 5 9 3 9 8 8 10 8 7 10 3 1 1 9 ... |
correct output |
---|
11 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 6
Verdict: RUNTIME ERROR
input |
---|
10 9
9 9 3 3 3 4 1 7 1 9 3 9 10 5 6 6 9 6 9 6 3 8 8 6 ... |
correct output |
---|
19 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 7
Verdict: RUNTIME ERROR
input |
---|
10 1
3 4 2 2 2 10 1 5 10 3 10 8 7 6 2 10 1 6 1 3 2 3 10 4 ... |
correct output |
---|
15 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 8
Verdict: RUNTIME ERROR
input |
---|
10 10
80 58 90 31 79 35 10 75 83 70 48 2 25 73 99 7 53 79 36 89 9 4 7 9 ... |
correct output |
---|
54 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 9
Verdict: RUNTIME ERROR
input |
---|
10 9
50 84 12 34 86 71 73 78 6 62 29 97 88 56 84 94 94 98 36 96 5 10 3 1 ... |
correct output |
---|
149 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 10
Verdict: RUNTIME ERROR
input |
---|
10 5
7 66 89 87 27 80 2 11 29 3 98 7 52 66 21 2 26 19 96 31 4 6 1 10 ... |
correct output |
---|
226 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 11
Verdict: RUNTIME ERROR
input |
---|
10 3
91 13 67 44 6 83 21 8 23 14 54 19 30 26 60 73 22 90 36 84 5 10 4 2 ... |
correct output |
---|
151 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 12
Verdict: RUNTIME ERROR
input |
---|
10 5
87 61 47 96 50 23 35 54 26 87 16 60 77 75 77 91 59 16 23 51 5 1 10 8 ... |
correct output |
---|
175 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 13
Verdict: RUNTIME ERROR
input |
---|
97304 87743
876894525 229121152 393060078 ... |
correct output |
---|
131459576065 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 14
Verdict: RUNTIME ERROR
input |
---|
74779 53246
763040787 482885163 932005790 ... |
correct output |
---|
155373737827 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 15
Verdict: RUNTIME ERROR
input |
---|
89537 85789
432185633 432110306 240073971 ... |
correct output |
---|
255801753825 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 16
Verdict: RUNTIME ERROR
input |
---|
99086 49261
283011093 775415197 945248913 ... |
correct output |
---|
162897193427 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 17
Verdict: RUNTIME ERROR
input |
---|
95142 68716
163121171 100246843 163249744 ... |
correct output |
---|
181966887510 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 18
Verdict: RUNTIME ERROR
input |
---|
19 3
49 73 32 44 84 29 9 76 77 36 9... |
correct output |
---|
147 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 19
Verdict: RUNTIME ERROR
input |
---|
19 6
68 94 70 46 91 47 67 100 62 23... |
correct output |
---|
244 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 20
Verdict: RUNTIME ERROR
input |
---|
18 3
90 65 90 80 41 5 95 17 53 7 29... |
correct output |
---|
127 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 21
Verdict: RUNTIME ERROR
input |
---|
16 1
48 91 87 2 16 39 92 26 1 68 78... |
correct output |
---|
224 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 22
Verdict: RUNTIME ERROR
input |
---|
15 2
11 1 37 1 8 20 24 59 42 52 91 ... |
correct output |
---|
219 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 23
Verdict: RUNTIME ERROR
input |
---|
94171 47986
552466372 215830212 408722990 ... |
correct output |
---|
150760767335 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 24
Verdict: RUNTIME ERROR
input |
---|
94221 86537
45774448 992088337 309200563 7... |
correct output |
---|
105016024608 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 25
Verdict: RUNTIME ERROR
input |
---|
96867 68461
39428919 749383323 481367036 5... |
correct output |
---|
219609902823 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 26
Verdict: RUNTIME ERROR
input |
---|
96077 83268
95064821 23000135 276477667 48... |
correct output |
---|
140845793522 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 27
Verdict: RUNTIME ERROR
input |
---|
99950 74867
864529930 269063846 767129921 ... |
correct output |
---|
217758011647 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 28
Verdict: RUNTIME ERROR
input |
---|
97182 41080
671075894 704355936 662862756 ... |
correct output |
---|
167687874177 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 29
Verdict: RUNTIME ERROR
input |
---|
96113 18731
554071104 111523361 276689875 ... |
correct output |
---|
207695993751 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 30
Verdict: RUNTIME ERROR
input |
---|
92311 6858
440850686 890390689 572816739 ... |
correct output |
---|
150986466317 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 31
Verdict: RUNTIME ERROR
input |
---|
99999 25726
949775640 24729596 158203669 2... |
correct output |
---|
125772383324 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...
Test 32
Verdict: RUNTIME ERROR
input |
---|
97857 32129
20264277 670255203 316861628 1... |
correct output |
---|
182392362837 |
user output |
---|
(empty) |
Error:
File "input/code.py", line 17 nonlocal max_charge ^ SyntaxError: invali...