#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[v] = 0;
c[u] -= c[v];
}
}
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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
4 |
Incorrect |
52 ms |
9816 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
4308 KB |
Output isn't correct |
13 |
Incorrect |
42 ms |
8708 KB |
Output isn't correct |
14 |
Incorrect |
46 ms |
9576 KB |
Output isn't correct |
15 |
Incorrect |
54 ms |
9900 KB |
Output isn't correct |
16 |
Incorrect |
42 ms |
9036 KB |
Output isn't correct |
17 |
Incorrect |
62 ms |
9868 KB |
Output isn't correct |
18 |
Incorrect |
61 ms |
9932 KB |
Output isn't correct |
19 |
Incorrect |
60 ms |
12492 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
22 |
Incorrect |
55 ms |
9936 KB |
Output isn't correct |
23 |
Incorrect |
38 ms |
8664 KB |
Output isn't correct |
24 |
Incorrect |
67 ms |
9976 KB |
Output isn't correct |
25 |
Incorrect |
59 ms |
8932 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
4180 KB |
Output isn't correct |
3 |
Incorrect |
41 ms |
9160 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 |
2 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 |
2 ms |
4180 KB |
Output isn't correct |
15 |
Incorrect |
2 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 |
2 ms |
4180 KB |
Output is correct |
19 |
Correct |
3 ms |
4180 KB |
Output is correct |
20 |
Correct |
3 ms |
4224 KB |
Output is correct |
21 |
Correct |
2 ms |
4180 KB |
Output is correct |
22 |
Incorrect |
3 ms |
4180 KB |
Output isn't correct |
23 |
Incorrect |
36 ms |
8236 KB |
Output isn't correct |
24 |
Incorrect |
45 ms |
9288 KB |
Output isn't correct |
25 |
Incorrect |
43 ms |
9100 KB |
Output isn't correct |
26 |
Correct |
2 ms |
4180 KB |
Output is correct |
27 |
Correct |
2 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 |
46 ms |
9040 KB |
Output isn't correct |
31 |
Incorrect |
49 ms |
9084 KB |
Output isn't correct |
32 |
Incorrect |
42 ms |
9504 KB |
Output isn't correct |
33 |
Incorrect |
45 ms |
9320 KB |
Output isn't correct |
34 |
Correct |
2 ms |
4180 KB |
Output is correct |
35 |
Correct |
2 ms |
4180 KB |
Output is correct |
36 |
Correct |
2 ms |
4180 KB |
Output is correct |
37 |
Correct |
3 ms |
4180 KB |
Output is correct |
38 |
Incorrect |
61 ms |
9300 KB |
Output isn't correct |
39 |
Incorrect |
56 ms |
9516 KB |
Output isn't correct |
40 |
Incorrect |
46 ms |
9392 KB |
Output isn't correct |
41 |
Incorrect |
43 ms |
9052 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 |
2 ms |
4180 KB |
Output is correct |
46 |
Incorrect |
42 ms |
9080 KB |
Output isn't correct |
47 |
Incorrect |
42 ms |
9292 KB |
Output isn't correct |
48 |
Incorrect |
41 ms |
9144 KB |
Output isn't correct |
49 |
Incorrect |
43 ms |
9296 KB |
Output isn't correct |
50 |
Correct |
2 ms |
4180 KB |
Output is correct |
51 |
Correct |
2 ms |
4180 KB |
Output is correct |
52 |
Correct |
3 ms |
4180 KB |
Output is correct |
53 |
Correct |
2 ms |
4180 KB |
Output is correct |
54 |
Incorrect |
50 ms |
9088 KB |
Output isn't correct |