# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1077476 |
2024-08-27T07:35:00 Z |
hung_nm |
Pipes (BOI13_pipes) |
C++17 |
|
138 ms |
56912 KB |
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
#define pipii pair<int, pair<int, int>>
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
#define int long long
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
using namespace std;
long long n, m, c[N], ans[N];
vpi ad[N];
void dfs(int u, int p)
{
long long res = 0;
for(auto [v, pos] : ad[u])
{
if(v == p) continue ;
dfs(v, u);
ans[pos] = 2 * c[v];
c[u] += c[v];
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; ++i)
{
cin >> c[i];
}
for(int i = 1; i <= m; ++i)
{
int u, v;
cin >> u >> v;
ad[u].pb({v, i});
ad[v].pb({u, i});
}
if(m != (n-1))
{
cout << 0;
return 0;
}
dfs(1, 0);
for(int i = 1; i <= m; ++i)
{
cout << 2*ans[i] << "\n";
}
return 0;
}
Compilation message
pipes.cpp: In function 'void dfs(long long int, long long int)':
pipes.cpp:19:15: warning: unused variable 'res' [-Wunused-variable]
19 | long long res = 0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
23896 KB |
Output isn't correct |
2 |
Incorrect |
13 ms |
23900 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
23896 KB |
Output isn't correct |
4 |
Incorrect |
49 ms |
32596 KB |
Output isn't correct |
5 |
Incorrect |
11 ms |
23896 KB |
Output isn't correct |
6 |
Incorrect |
12 ms |
23900 KB |
Output isn't correct |
7 |
Incorrect |
12 ms |
23900 KB |
Output isn't correct |
8 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
9 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
10 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
11 |
Incorrect |
10 ms |
23896 KB |
Output isn't correct |
12 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
13 |
Incorrect |
40 ms |
30804 KB |
Output isn't correct |
14 |
Incorrect |
42 ms |
32064 KB |
Output isn't correct |
15 |
Incorrect |
47 ms |
32592 KB |
Output isn't correct |
16 |
Incorrect |
45 ms |
31152 KB |
Output isn't correct |
17 |
Incorrect |
48 ms |
32592 KB |
Output isn't correct |
18 |
Incorrect |
47 ms |
32536 KB |
Output isn't correct |
19 |
Incorrect |
59 ms |
36692 KB |
Output isn't correct |
20 |
Incorrect |
12 ms |
23964 KB |
Output isn't correct |
21 |
Incorrect |
12 ms |
23900 KB |
Output isn't correct |
22 |
Incorrect |
45 ms |
32716 KB |
Output isn't correct |
23 |
Incorrect |
42 ms |
30804 KB |
Output isn't correct |
24 |
Incorrect |
48 ms |
32596 KB |
Output isn't correct |
25 |
Incorrect |
44 ms |
31084 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23900 KB |
Output isn't correct |
2 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
3 |
Correct |
39 ms |
30992 KB |
Output is correct |
4 |
Correct |
39 ms |
31312 KB |
Output is correct |
5 |
Correct |
45 ms |
31060 KB |
Output is correct |
6 |
Correct |
136 ms |
56912 KB |
Output is correct |
7 |
Incorrect |
11 ms |
23896 KB |
Output isn't correct |
8 |
Incorrect |
11 ms |
23964 KB |
Output isn't correct |
9 |
Correct |
11 ms |
23900 KB |
Output is correct |
10 |
Correct |
10 ms |
23900 KB |
Output is correct |
11 |
Correct |
10 ms |
23972 KB |
Output is correct |
12 |
Correct |
10 ms |
23776 KB |
Output is correct |
13 |
Correct |
10 ms |
23900 KB |
Output is correct |
14 |
Incorrect |
12 ms |
23900 KB |
Output isn't correct |
15 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
16 |
Incorrect |
11 ms |
23896 KB |
Output isn't correct |
17 |
Correct |
11 ms |
24028 KB |
Output is correct |
18 |
Correct |
15 ms |
23956 KB |
Output is correct |
19 |
Correct |
11 ms |
23900 KB |
Output is correct |
20 |
Correct |
11 ms |
24152 KB |
Output is correct |
21 |
Correct |
12 ms |
23900 KB |
Output is correct |
22 |
Incorrect |
13 ms |
23816 KB |
Output isn't correct |
23 |
Incorrect |
35 ms |
29852 KB |
Output isn't correct |
24 |
Incorrect |
45 ms |
31316 KB |
Output isn't correct |
25 |
Correct |
40 ms |
30924 KB |
Output is correct |
26 |
Correct |
48 ms |
31492 KB |
Output is correct |
27 |
Correct |
41 ms |
31312 KB |
Output is correct |
28 |
Correct |
43 ms |
31576 KB |
Output is correct |
29 |
Correct |
104 ms |
50408 KB |
Output is correct |
30 |
Incorrect |
39 ms |
31060 KB |
Output isn't correct |
31 |
Incorrect |
40 ms |
31280 KB |
Output isn't correct |
32 |
Incorrect |
45 ms |
31628 KB |
Output isn't correct |
33 |
Correct |
40 ms |
31316 KB |
Output is correct |
34 |
Correct |
40 ms |
31512 KB |
Output is correct |
35 |
Correct |
44 ms |
31428 KB |
Output is correct |
36 |
Correct |
43 ms |
31400 KB |
Output is correct |
37 |
Correct |
138 ms |
56656 KB |
Output is correct |
38 |
Incorrect |
45 ms |
31320 KB |
Output isn't correct |
39 |
Incorrect |
42 ms |
31220 KB |
Output isn't correct |
40 |
Incorrect |
36 ms |
31456 KB |
Output isn't correct |
41 |
Correct |
42 ms |
31308 KB |
Output is correct |
42 |
Correct |
40 ms |
31256 KB |
Output is correct |
43 |
Correct |
44 ms |
31312 KB |
Output is correct |
44 |
Correct |
40 ms |
31056 KB |
Output is correct |
45 |
Correct |
99 ms |
53072 KB |
Output is correct |
46 |
Incorrect |
43 ms |
31316 KB |
Output isn't correct |
47 |
Incorrect |
41 ms |
31312 KB |
Output isn't correct |
48 |
Incorrect |
39 ms |
31316 KB |
Output isn't correct |
49 |
Correct |
38 ms |
30936 KB |
Output is correct |
50 |
Correct |
40 ms |
31316 KB |
Output is correct |
51 |
Correct |
36 ms |
31320 KB |
Output is correct |
52 |
Correct |
44 ms |
31312 KB |
Output is correct |
53 |
Correct |
105 ms |
52568 KB |
Output is correct |
54 |
Incorrect |
42 ms |
31320 KB |
Output isn't correct |