Task: | Chain Reaction |
Sender: | aalto2024m_001 |
Submission time: | 2024-11-25 16:50:23 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | WRONG ANSWER | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.19 s | details |
#14 | WRONG ANSWER | 0.14 s | details |
#15 | WRONG ANSWER | 0.17 s | details |
#16 | WRONG ANSWER | 0.19 s | details |
#17 | WRONG ANSWER | 0.19 s | details |
#18 | WRONG ANSWER | 0.00 s | details |
#19 | WRONG ANSWER | 0.00 s | details |
#20 | WRONG ANSWER | 0.00 s | details |
#21 | WRONG ANSWER | 0.00 s | details |
#22 | WRONG ANSWER | 0.00 s | details |
#23 | WRONG ANSWER | 0.21 s | details |
#24 | WRONG ANSWER | 0.18 s | details |
#25 | WRONG ANSWER | 0.19 s | details |
#26 | WRONG ANSWER | 0.19 s | details |
#27 | WRONG ANSWER | 0.20 s | details |
#28 | WRONG ANSWER | 0.19 s | details |
#29 | WRONG ANSWER | 0.19 s | details |
#30 | WRONG ANSWER | 0.18 s | details |
#31 | WRONG ANSWER | 0.20 s | details |
#32 | WRONG ANSWER | 0.19 s | details |
Code
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<vector<int>> tree; vector<int> neutrones, protones; vector<bool> visited; int max_charge = 1; void dfs(int node, int charge) { visited[node] = true; max_charge = max(max_charge, charge); for (int neighbor : tree[node]) { if (!visited[neighbor]) { int charge_with_neutrones = charge + (neutrones[neighbor] - neutrones[node]); int charge_with_protones = charge + (protones[neighbor] - protones[node]); dfs(neighbor, charge_with_neutrones); dfs(neighbor, charge_with_protones); } } } int main() { int n, s; cin >> n >> s; s-=1; neutrones.resize(n); protones.resize(n); tree.resize(n); visited.resize(n, false); for (int i = 0; i < n; i++) { cin >> neutrones[i]; } for (int i = 0; i < n; i++) { cin >> protones[i]; } for (int i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; u--; v--; tree[u].push_back(v); tree[v].push_back(u); } dfs(s, 1); cout << max_charge << endl; return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
5 1
4 2 1 1 1 5 2 1 5 4 1 2 1 3 ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 2
Verdict: ACCEPTED
input |
---|
4 1
4 2 2 1 1 1 1 1 1 2 2 3 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: WRONG ANSWER
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 |
---|
12 |
Test 4
Verdict: WRONG ANSWER
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 |
---|
4 |
Test 5
Verdict: WRONG ANSWER
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 |
---|
8 |
Test 6
Verdict: WRONG ANSWER
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 |
---|
9 |
Test 7
Verdict: ACCEPTED
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 |
---|
15 |
Test 8
Verdict: WRONG ANSWER
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 |
---|
35 |
Test 9
Verdict: WRONG ANSWER
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 |
---|
104 |
Test 10
Verdict: WRONG ANSWER
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 |
---|
118 |
Test 11
Verdict: WRONG ANSWER
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 |
---|
55 |
Test 12
Verdict: WRONG ANSWER
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 |
---|
81 |
Test 13
Verdict: WRONG ANSWER
input |
---|
97304 87743
876894525 229121152 393060078 ... |
correct output |
---|
131459576065 |
user output |
---|
1330218946 |
Test 14
Verdict: WRONG ANSWER
input |
---|
74779 53246
763040787 482885163 932005790 ... |
correct output |
---|
155373737827 |
user output |
---|
1492699163 |
Test 15
Verdict: WRONG ANSWER
input |
---|
89537 85789
432185633 432110306 240073971 ... |
correct output |
---|
255801753825 |
user output |
---|
1454269985 |
Test 16
Verdict: WRONG ANSWER
input |
---|
99086 49261
283011093 775415197 945248913 ... |
correct output |
---|
162897193427 |
user output |
---|
1872440316 |
Test 17
Verdict: WRONG ANSWER
input |
---|
95142 68716
163121171 100246843 163249744 ... |
correct output |
---|
181966887510 |
user output |
---|
1411335319 |
Test 18
Verdict: WRONG ANSWER
input |
---|
19 3
49 73 32 44 84 29 9 76 77 36 9... |
correct output |
---|
147 |
user output |
---|
77 |
Test 19
Verdict: WRONG ANSWER
input |
---|
19 6
68 94 70 46 91 47 67 100 62 23... |
correct output |
---|
244 |
user output |
---|
112 |
Test 20
Verdict: WRONG ANSWER
input |
---|
18 3
90 65 90 80 41 5 95 17 53 7 29... |
correct output |
---|
127 |
user output |
---|
82 |
Test 21
Verdict: WRONG ANSWER
input |
---|
16 1
48 91 87 2 16 39 92 26 1 68 78... |
correct output |
---|
224 |
user output |
---|
102 |
Test 22
Verdict: WRONG ANSWER
input |
---|
15 2
11 1 37 1 8 20 24 59 42 52 91 ... |
correct output |
---|
219 |
user output |
---|
130 |
Test 23
Verdict: WRONG ANSWER
input |
---|
94171 47986
552466372 215830212 408722990 ... |
correct output |
---|
150760767335 |
user output |
---|
1352671839 |
Test 24
Verdict: WRONG ANSWER
input |
---|
94221 86537
45774448 992088337 309200563 7... |
correct output |
---|
105016024608 |
user output |
---|
1747547814 |
Test 25
Verdict: WRONG ANSWER
input |
---|
96867 68461
39428919 749383323 481367036 5... |
correct output |
---|
219609902823 |
user output |
---|
1871651722 |
Test 26
Verdict: WRONG ANSWER
input |
---|
96077 83268
95064821 23000135 276477667 48... |
correct output |
---|
140845793522 |
user output |
---|
1829743179 |
Test 27
Verdict: WRONG ANSWER
input |
---|
99950 74867
864529930 269063846 767129921 ... |
correct output |
---|
217758011647 |
user output |
---|
1566165746 |
Test 28
Verdict: WRONG ANSWER
input |
---|
97182 41080
671075894 704355936 662862756 ... |
correct output |
---|
167687874177 |
user output |
---|
1053843709 |
Test 29
Verdict: WRONG ANSWER
input |
---|
96113 18731
554071104 111523361 276689875 ... |
correct output |
---|
207695993751 |
user output |
---|
994308907 |
Test 30
Verdict: WRONG ANSWER
input |
---|
92311 6858
440850686 890390689 572816739 ... |
correct output |
---|
150986466317 |
user output |
---|
1179166857 |
Test 31
Verdict: WRONG ANSWER
input |
---|
99999 25726
949775640 24729596 158203669 2... |
correct output |
---|
125772383324 |
user output |
---|
1355629014 |
Test 32
Verdict: WRONG ANSWER
input |
---|
97857 32129
20264277 670255203 316861628 1... |
correct output |
---|
182392362837 |
user output |
---|
1410813540 |