# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
555862 |
2022-05-01T18:04:53 Z |
blue |
Pipes (BOI13_pipes) |
C++17 |
|
70 ms |
11596 KB |
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vll = vector<ll>;
const int mx = 100'000;
int N, M;
vpii edge[1+mx];
vll c(1+mx);
vll x(1+mx);
void dfs(int u, int p)
{
for(pii vp : edge[u])
{
int v = vp.first;
int e = vp.second;
if(v == p) continue;
dfs(v, u);
x[e] = 2*c[v];
c[u] -= c[v];
c[v] = 0;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
if(M > N)
{
cout << "0\n";
return 0;
}
for(int i = 1; i <= N; i++) cin >> c[i];
for(int j = 1; j <= M; j++)
{
int u, v;
cin >> u >> v;
edge[u].push_back({v, j});
edge[v].push_back({u, j});
}
if(M == N-1)
{
dfs(1, 0);
}
for(int e = 1; e <= M; e++)
cout << x[e] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Correct |
2 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4180 KB |
Output is correct |
4 |
Correct |
56 ms |
8344 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4172 KB |
Output is correct |
7 |
Correct |
2 ms |
4180 KB |
Output is correct |
8 |
Correct |
2 ms |
4180 KB |
Output is correct |
9 |
Correct |
3 ms |
4180 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
2 ms |
4180 KB |
Output is correct |
12 |
Correct |
2 ms |
4308 KB |
Output is correct |
13 |
Correct |
38 ms |
7524 KB |
Output is correct |
14 |
Correct |
44 ms |
8140 KB |
Output is correct |
15 |
Correct |
47 ms |
8352 KB |
Output is correct |
16 |
Correct |
54 ms |
7736 KB |
Output is correct |
17 |
Correct |
55 ms |
8292 KB |
Output is correct |
18 |
Correct |
47 ms |
8300 KB |
Output is correct |
19 |
Correct |
51 ms |
11596 KB |
Output is correct |
20 |
Correct |
2 ms |
4184 KB |
Output is correct |
21 |
Correct |
2 ms |
4180 KB |
Output is correct |
22 |
Correct |
47 ms |
8348 KB |
Output is correct |
23 |
Correct |
39 ms |
7500 KB |
Output is correct |
24 |
Correct |
48 ms |
8372 KB |
Output is correct |
25 |
Correct |
44 ms |
7656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
3 |
Incorrect |
40 ms |
7668 KB |
Output isn't correct |
4 |
Correct |
2 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
10 |
Correct |
2 ms |
4180 KB |
Output is correct |
11 |
Correct |
2 ms |
4180 KB |
Output is correct |
12 |
Correct |
2 ms |
4180 KB |
Output is correct |
13 |
Correct |
2 ms |
4180 KB |
Output is correct |
14 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
18 |
Correct |
3 ms |
4180 KB |
Output is correct |
19 |
Correct |
3 ms |
4180 KB |
Output is correct |
20 |
Correct |
2 ms |
4180 KB |
Output is correct |
21 |
Correct |
3 ms |
4180 KB |
Output is correct |
22 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
23 |
Incorrect |
37 ms |
7116 KB |
Output isn't correct |
24 |
Incorrect |
45 ms |
7792 KB |
Output isn't correct |
25 |
Incorrect |
44 ms |
7656 KB |
Output isn't correct |
26 |
Correct |
2 ms |
4180 KB |
Output is correct |
27 |
Correct |
4 ms |
4180 KB |
Output is correct |
28 |
Correct |
2 ms |
4180 KB |
Output is correct |
29 |
Correct |
2 ms |
4180 KB |
Output is correct |
30 |
Incorrect |
70 ms |
7484 KB |
Output isn't correct |
31 |
Incorrect |
47 ms |
7572 KB |
Output isn't correct |
32 |
Incorrect |
61 ms |
8000 KB |
Output isn't correct |
33 |
Incorrect |
53 ms |
7716 KB |
Output isn't correct |
34 |
Correct |
3 ms |
4180 KB |
Output is correct |
35 |
Correct |
3 ms |
4180 KB |
Output is correct |
36 |
Correct |
3 ms |
4180 KB |
Output is correct |
37 |
Correct |
2 ms |
4180 KB |
Output is correct |
38 |
Incorrect |
54 ms |
7700 KB |
Output isn't correct |
39 |
Incorrect |
57 ms |
8064 KB |
Output isn't correct |
40 |
Incorrect |
58 ms |
7788 KB |
Output isn't correct |
41 |
Incorrect |
48 ms |
7528 KB |
Output isn't correct |
42 |
Correct |
2 ms |
4180 KB |
Output is correct |
43 |
Correct |
2 ms |
4180 KB |
Output is correct |
44 |
Correct |
2 ms |
4180 KB |
Output is correct |
45 |
Correct |
3 ms |
4180 KB |
Output is correct |
46 |
Incorrect |
49 ms |
7572 KB |
Output isn't correct |
47 |
Incorrect |
42 ms |
7844 KB |
Output isn't correct |
48 |
Incorrect |
52 ms |
7572 KB |
Output isn't correct |
49 |
Incorrect |
48 ms |
7824 KB |
Output isn't correct |
50 |
Correct |
3 ms |
4180 KB |
Output is correct |
51 |
Correct |
2 ms |
4212 KB |
Output is correct |
52 |
Correct |
3 ms |
4156 KB |
Output is correct |
53 |
Correct |
2 ms |
4180 KB |
Output is correct |
54 |
Incorrect |
57 ms |
7588 KB |
Output isn't correct |