# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
755486 |
2023-06-10T07:33:46 Z |
drdilyor |
Pipes (BOI13_pipes) |
C++17 |
|
60 ms |
9296 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
if (n != m+1) {
cout << 0 << '\n';
return 0;
}
vector<int> arr(n);
for (int& i : arr) cin >> i;
vector<vector<pair<int,int>>> adj(n);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--;v--;
adj[u].push_back({v, i});
adj[v].push_back({u, i});
}
vector<int> ans(m);
auto dfs = [&](auto& dfs, int i, int p =-1,int pei=-1) ->void {
int c = 0;
for (auto [e, ei]: adj[i]) {
if (e == p) continue;
c++;
dfs(dfs, e, i, ei);
}
if (p!=-1) {
ans[pei] = arr[i];
arr[p] -= arr[i];
}
};
dfs(dfs, 0);
for (int i : ans) cout << i*2<< ' ';
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
58 ms |
7548 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
44 ms |
6036 KB |
Output is correct |
14 |
Correct |
52 ms |
7176 KB |
Output is correct |
15 |
Correct |
55 ms |
7580 KB |
Output is correct |
16 |
Correct |
44 ms |
6496 KB |
Output is correct |
17 |
Correct |
57 ms |
7628 KB |
Output is correct |
18 |
Correct |
53 ms |
7608 KB |
Output is correct |
19 |
Correct |
60 ms |
9296 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
52 ms |
7572 KB |
Output is correct |
23 |
Correct |
38 ms |
6032 KB |
Output is correct |
24 |
Correct |
48 ms |
7532 KB |
Output is correct |
25 |
Correct |
46 ms |
6340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
24 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
31 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
39 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
40 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
47 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
48 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
0 ms |
212 KB |
Output is correct |
51 |
Correct |
0 ms |
212 KB |
Output is correct |
52 |
Correct |
0 ms |
212 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |