# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106157 | 2019-04-16T22:23:45 Z | luciocf | Pipes (BOI13_pipes) | C++14 | 302 ms | 23244 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; const int maxm = 5e5+10; typedef pair<int, int> pii; int a[maxn], cur[maxn]; int edge[maxn], costEdge[maxm]; vector<pii> grafo[maxn]; void dfs(int u, int p) { for (auto pp: grafo[u]) { int v = pp.first, e = pp.second; if (v == p) continue; edge[v] = e; dfs(v, u); cur[u] += costEdge[e]/2; } if (u != 1) { costEdge[edge[u]] = 2*(a[u]-cur[u]); cur[u] = a[u]; } } int main(void) { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= m; i++) { int u, v; scanf("%d %d", &u, &v); grafo[u].push_back({v, i}); grafo[v].push_back({u, i}); } if (m != n-1) { printf("0\n"); return 0; } dfs(1, 0); if (cur[1] != a[1]) printf("0\n"); else { for (int i = 1; i <= m; i++) printf("%d\n", costEdge[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2688 KB | Output is correct |
2 | Correct | 4 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 89 ms | 8440 KB | Output is correct |
5 | Correct | 4 ms | 2688 KB | Output is correct |
6 | Correct | 4 ms | 2688 KB | Output is correct |
7 | Correct | 4 ms | 2688 KB | Output is correct |
8 | Correct | 4 ms | 2688 KB | Output is correct |
9 | Correct | 4 ms | 2816 KB | Output is correct |
10 | Correct | 4 ms | 2688 KB | Output is correct |
11 | Correct | 4 ms | 2688 KB | Output is correct |
12 | Correct | 4 ms | 2736 KB | Output is correct |
13 | Correct | 66 ms | 7272 KB | Output is correct |
14 | Correct | 77 ms | 8060 KB | Output is correct |
15 | Correct | 85 ms | 8400 KB | Output is correct |
16 | Correct | 65 ms | 7520 KB | Output is correct |
17 | Correct | 83 ms | 8440 KB | Output is correct |
18 | Correct | 79 ms | 8440 KB | Output is correct |
19 | Correct | 96 ms | 11040 KB | Output is correct |
20 | Correct | 4 ms | 2688 KB | Output is correct |
21 | Correct | 4 ms | 2688 KB | Output is correct |
22 | Correct | 105 ms | 8444 KB | Output is correct |
23 | Correct | 65 ms | 7288 KB | Output is correct |
24 | Correct | 87 ms | 8440 KB | Output is correct |
25 | Correct | 75 ms | 7672 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 2732 KB | Output isn't correct |
2 | Incorrect | 4 ms | 2688 KB | Output isn't correct |
3 | Correct | 58 ms | 7848 KB | Output is correct |
4 | Correct | 67 ms | 7928 KB | Output is correct |
5 | Correct | 69 ms | 8184 KB | Output is correct |
6 | Correct | 302 ms | 23160 KB | Output is correct |
7 | Incorrect | 4 ms | 2688 KB | Output isn't correct |
8 | Incorrect | 4 ms | 2688 KB | Output isn't correct |
9 | Correct | 5 ms | 2688 KB | Output is correct |
10 | Correct | 5 ms | 2688 KB | Output is correct |
11 | Correct | 4 ms | 2688 KB | Output is correct |
12 | Correct | 5 ms | 2688 KB | Output is correct |
13 | Correct | 5 ms | 2688 KB | Output is correct |
14 | Incorrect | 4 ms | 2688 KB | Output isn't correct |
15 | Incorrect | 5 ms | 2688 KB | Output isn't correct |
16 | Incorrect | 5 ms | 2688 KB | Output isn't correct |
17 | Correct | 5 ms | 2688 KB | Output is correct |
18 | Correct | 4 ms | 2688 KB | Output is correct |
19 | Correct | 5 ms | 2688 KB | Output is correct |
20 | Correct | 6 ms | 2816 KB | Output is correct |
21 | Correct | 5 ms | 2816 KB | Output is correct |
22 | Incorrect | 5 ms | 2688 KB | Output isn't correct |
23 | Incorrect | 74 ms | 7032 KB | Output isn't correct |
24 | Incorrect | 80 ms | 8060 KB | Output isn't correct |
25 | Correct | 61 ms | 7928 KB | Output is correct |
26 | Correct | 67 ms | 7976 KB | Output is correct |
27 | Correct | 85 ms | 7800 KB | Output is correct |
28 | Correct | 85 ms | 8412 KB | Output is correct |
29 | Correct | 222 ms | 19420 KB | Output is correct |
30 | Incorrect | 70 ms | 7672 KB | Output isn't correct |
31 | Incorrect | 72 ms | 7808 KB | Output isn't correct |
32 | Incorrect | 60 ms | 6648 KB | Output isn't correct |
33 | Correct | 63 ms | 8056 KB | Output is correct |
34 | Correct | 61 ms | 8056 KB | Output is correct |
35 | Correct | 62 ms | 7928 KB | Output is correct |
36 | Correct | 64 ms | 8312 KB | Output is correct |
37 | Correct | 301 ms | 23244 KB | Output is correct |
38 | Incorrect | 59 ms | 7928 KB | Output isn't correct |
39 | Incorrect | 72 ms | 6840 KB | Output isn't correct |
40 | Incorrect | 80 ms | 8056 KB | Output isn't correct |
41 | Correct | 83 ms | 7800 KB | Output is correct |
42 | Correct | 76 ms | 7836 KB | Output is correct |
43 | Correct | 113 ms | 7800 KB | Output is correct |
44 | Correct | 71 ms | 8056 KB | Output is correct |
45 | Correct | 261 ms | 20472 KB | Output is correct |
46 | Incorrect | 69 ms | 6272 KB | Output isn't correct |
47 | Incorrect | 89 ms | 8076 KB | Output isn't correct |
48 | Incorrect | 81 ms | 7928 KB | Output isn't correct |
49 | Correct | 60 ms | 6524 KB | Output is correct |
50 | Correct | 78 ms | 8056 KB | Output is correct |
51 | Correct | 67 ms | 8056 KB | Output is correct |
52 | Correct | 73 ms | 7824 KB | Output is correct |
53 | Correct | 268 ms | 20496 KB | Output is correct |
54 | Incorrect | 62 ms | 7800 KB | Output isn't correct |