# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
885114 |
2023-12-09T03:00:46 Z |
12345678 |
Pipes (BOI13_pipes) |
C++17 |
|
114 ms |
38484 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e5+5;
int n, m, h[nx], u, v, sz, res[nx], vs[nx], lvl[nx], f;
vector<pair<int, int>> d[nx];
void dfs(int u, int p, int idx)
{
vs[u]=1; lvl[u]=lvl[p]+1;
for (auto [v, id]:d[u])
{
if (v==p) continue;
if (!vs[v]) dfs(v, u, id);
else if ((lvl[u]-lvl[v]+1)%2==0) f=1;
}
if (idx==-1) return;
res[idx]=2*h[u];
h[p]-=h[u];
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=n; i++) cin>>h[i];
for (int i=1; i<=m; i++) cin>>u>>v, d[u].push_back({v, i}), d[v].push_back({u, i});
dfs(1, 1, -1);
if (m>n||f)
{
cout<<0;
return 0;
}
for (int i=1; i<n; i++) cout<<res[i]<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
45 ms |
8276 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2904 KB |
Output is correct |
13 |
Correct |
29 ms |
7184 KB |
Output is correct |
14 |
Correct |
36 ms |
8016 KB |
Output is correct |
15 |
Correct |
39 ms |
8368 KB |
Output is correct |
16 |
Correct |
36 ms |
7508 KB |
Output is correct |
17 |
Correct |
37 ms |
8448 KB |
Output is correct |
18 |
Correct |
35 ms |
8528 KB |
Output is correct |
19 |
Correct |
40 ms |
11604 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
35 ms |
8316 KB |
Output is correct |
23 |
Correct |
28 ms |
7320 KB |
Output is correct |
24 |
Correct |
35 ms |
8532 KB |
Output is correct |
25 |
Correct |
28 ms |
7508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
2908 KB |
Output isn't correct |
3 |
Correct |
31 ms |
10868 KB |
Output is correct |
4 |
Correct |
35 ms |
13796 KB |
Output is correct |
5 |
Correct |
30 ms |
7952 KB |
Output is correct |
6 |
Runtime error |
114 ms |
38484 KB |
Execution killed with signal 11 |
7 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
2908 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
17 |
Correct |
1 ms |
2904 KB |
Output is correct |
18 |
Correct |
1 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2908 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2908 KB |
Output is correct |
22 |
Incorrect |
1 ms |
2908 KB |
Output isn't correct |
23 |
Incorrect |
30 ms |
11092 KB |
Output isn't correct |
24 |
Incorrect |
39 ms |
12116 KB |
Output isn't correct |
25 |
Correct |
32 ms |
10844 KB |
Output is correct |
26 |
Correct |
34 ms |
12736 KB |
Output is correct |
27 |
Correct |
32 ms |
13148 KB |
Output is correct |
28 |
Correct |
30 ms |
7772 KB |
Output is correct |
29 |
Runtime error |
96 ms |
34748 KB |
Execution killed with signal 11 |
30 |
Incorrect |
42 ms |
14676 KB |
Output isn't correct |
31 |
Incorrect |
39 ms |
14672 KB |
Output isn't correct |
32 |
Incorrect |
41 ms |
9992 KB |
Output isn't correct |
33 |
Correct |
32 ms |
11856 KB |
Output is correct |
34 |
Correct |
31 ms |
11864 KB |
Output is correct |
35 |
Correct |
33 ms |
13392 KB |
Output is correct |
36 |
Correct |
29 ms |
7772 KB |
Output is correct |
37 |
Runtime error |
114 ms |
38484 KB |
Execution killed with signal 11 |
38 |
Incorrect |
39 ms |
13648 KB |
Output isn't correct |
39 |
Incorrect |
48 ms |
9128 KB |
Output isn't correct |
40 |
Incorrect |
37 ms |
11856 KB |
Output isn't correct |
41 |
Correct |
38 ms |
14172 KB |
Output is correct |
42 |
Correct |
32 ms |
12380 KB |
Output is correct |
43 |
Correct |
32 ms |
13912 KB |
Output is correct |
44 |
Correct |
29 ms |
7772 KB |
Output is correct |
45 |
Runtime error |
96 ms |
35664 KB |
Execution killed with signal 11 |
46 |
Incorrect |
54 ms |
15552 KB |
Output isn't correct |
47 |
Incorrect |
37 ms |
12120 KB |
Output isn't correct |
48 |
Incorrect |
43 ms |
14472 KB |
Output isn't correct |
49 |
Correct |
28 ms |
8792 KB |
Output is correct |
50 |
Correct |
32 ms |
12112 KB |
Output is correct |
51 |
Correct |
30 ms |
10076 KB |
Output is correct |
52 |
Correct |
29 ms |
9300 KB |
Output is correct |
53 |
Runtime error |
109 ms |
34584 KB |
Execution killed with signal 11 |
54 |
Incorrect |
38 ms |
13136 KB |
Output isn't correct |