# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111614 | 2019-05-15T17:38:45 Z | wilwxk | Pipes (BOI13_pipes) | C++11 | 445 ms | 27436 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN=1e5+5; vector<int> g[MAXN], lista[MAXN]; int v[MAXN], tenho[MAXN], resp[MAXN]; int n, m; void dfs(int cur, int p) { tenho[cur]=0; for(int i=0; i<g[cur].size(); i++) { int viz=g[cur][i]; int ind=lista[cur][i]; if(viz==p) continue; dfs(viz, cur); resp[ind]=v[viz]-tenho[viz]; tenho[cur]+=resp[ind]; } } int main() { scanf("%d %d", &n, &m); for(int i=1; i<=n; i++) scanf("%d", &v[i]); for(int i=1; i<=m; i++) { int a, b; scanf("%d %d", &a, &b); g[a].push_back(b); g[b].push_back(a); lista[a].push_back(i); lista[b].push_back(i); } if(m>n) { printf("0\n"); } else if(m==n-1) { dfs(1, 1); if(tenho[1]!=v[1]) { printf("0\n"); } else { for(int i=1; i<=m; i++) { printf("%d\n", resp[i]*2); } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4992 KB | Output is correct |
2 | Correct | 7 ms | 4992 KB | Output is correct |
3 | Correct | 7 ms | 5120 KB | Output is correct |
4 | Correct | 157 ms | 13068 KB | Output is correct |
5 | Correct | 6 ms | 5120 KB | Output is correct |
6 | Correct | 5 ms | 4992 KB | Output is correct |
7 | Correct | 7 ms | 5248 KB | Output is correct |
8 | Correct | 7 ms | 5120 KB | Output is correct |
9 | Correct | 10 ms | 5120 KB | Output is correct |
10 | Correct | 6 ms | 5120 KB | Output is correct |
11 | Correct | 7 ms | 5120 KB | Output is correct |
12 | Correct | 8 ms | 5120 KB | Output is correct |
13 | Correct | 117 ms | 11512 KB | Output is correct |
14 | Correct | 136 ms | 12792 KB | Output is correct |
15 | Correct | 134 ms | 13148 KB | Output is correct |
16 | Correct | 115 ms | 11900 KB | Output is correct |
17 | Correct | 152 ms | 13008 KB | Output is correct |
18 | Correct | 127 ms | 13048 KB | Output is correct |
19 | Correct | 136 ms | 16760 KB | Output is correct |
20 | Correct | 7 ms | 4992 KB | Output is correct |
21 | Correct | 8 ms | 5120 KB | Output is correct |
22 | Correct | 139 ms | 13176 KB | Output is correct |
23 | Correct | 118 ms | 11512 KB | Output is correct |
24 | Correct | 131 ms | 13048 KB | Output is correct |
25 | Correct | 95 ms | 11768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4964 KB | Output isn't correct |
2 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
3 | Incorrect | 83 ms | 12920 KB | Output isn't correct |
4 | Correct | 107 ms | 13304 KB | Output is correct |
5 | Correct | 104 ms | 13264 KB | Output is correct |
6 | Correct | 445 ms | 27436 KB | Output is correct |
7 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
8 | Incorrect | 8 ms | 4992 KB | Output isn't correct |
9 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
10 | Correct | 7 ms | 4992 KB | Output is correct |
11 | Correct | 7 ms | 5072 KB | Output is correct |
12 | Correct | 6 ms | 5120 KB | Output is correct |
13 | Correct | 6 ms | 5120 KB | Output is correct |
14 | Incorrect | 7 ms | 4992 KB | Output isn't correct |
15 | Incorrect | 6 ms | 5120 KB | Output isn't correct |
16 | Incorrect | 6 ms | 5120 KB | Output isn't correct |
17 | Incorrect | 8 ms | 5120 KB | Output isn't correct |
18 | Correct | 7 ms | 5120 KB | Output is correct |
19 | Correct | 6 ms | 5120 KB | Output is correct |
20 | Correct | 9 ms | 5120 KB | Output is correct |
21 | Correct | 10 ms | 5248 KB | Output is correct |
22 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
23 | Incorrect | 156 ms | 11768 KB | Output isn't correct |
24 | Incorrect | 130 ms | 13304 KB | Output isn't correct |
25 | Incorrect | 97 ms | 12920 KB | Output isn't correct |
26 | Correct | 110 ms | 13304 KB | Output is correct |
27 | Correct | 108 ms | 13176 KB | Output is correct |
28 | Correct | 112 ms | 13512 KB | Output is correct |
29 | Correct | 352 ms | 23592 KB | Output is correct |
30 | Incorrect | 101 ms | 13048 KB | Output isn't correct |
31 | Incorrect | 94 ms | 13300 KB | Output isn't correct |
32 | Incorrect | 106 ms | 13464 KB | Output isn't correct |
33 | Incorrect | 109 ms | 13432 KB | Output isn't correct |
34 | Correct | 125 ms | 13404 KB | Output is correct |
35 | Correct | 89 ms | 13276 KB | Output is correct |
36 | Correct | 104 ms | 13548 KB | Output is correct |
37 | Correct | 405 ms | 27128 KB | Output is correct |
38 | Incorrect | 99 ms | 13304 KB | Output isn't correct |
39 | Incorrect | 97 ms | 11768 KB | Output isn't correct |
40 | Incorrect | 115 ms | 13548 KB | Output isn't correct |
41 | Incorrect | 104 ms | 13252 KB | Output isn't correct |
42 | Correct | 106 ms | 13304 KB | Output is correct |
43 | Correct | 91 ms | 13308 KB | Output is correct |
44 | Correct | 103 ms | 13328 KB | Output is correct |
45 | Correct | 351 ms | 23516 KB | Output is correct |
46 | Incorrect | 97 ms | 11640 KB | Output isn't correct |
47 | Incorrect | 132 ms | 13304 KB | Output isn't correct |
48 | Incorrect | 108 ms | 13312 KB | Output isn't correct |
49 | Incorrect | 101 ms | 11516 KB | Output isn't correct |
50 | Correct | 112 ms | 13304 KB | Output is correct |
51 | Correct | 123 ms | 13360 KB | Output is correct |
52 | Correct | 107 ms | 13148 KB | Output is correct |
53 | Correct | 387 ms | 23940 KB | Output is correct |
54 | Incorrect | 90 ms | 13176 KB | Output isn't correct |