# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
755489 |
2023-06-10T07:40:20 Z |
The_Samurai |
Pipes (BOI13_pipes) |
C++17 |
|
59 ms |
8296 KB |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, m;
cin >> n >> m;
if (n != m + 1) {
return 0;
}
vector<vector<pair<int, int>>> g(n + 1);
vector<int> cnt(n + 1), ans(m), a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
g[u].emplace_back(v, i);
g[v].emplace_back(u, i);
}
queue<int> q;
vector<bool> vis(n + 1);
for (int i = 1; i <= n; i++) {
cnt[i] = g[i].size();
if (cnt[i] == 1) {
q.push(i);
}
}
while (!q.empty()) {
int u = q.front();
q.pop();
vis[u] = true;
for (auto [v, i]: g[u]) {
if (vis[v]) continue;
cnt[v]--;
if (cnt[v] == 1) q.push(v);
ans[i] = a[u] * 2;
a[v] -= a[u];
}
}
for (int x: ans) cout << x << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
260 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
55 ms |
8296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
42 ms |
6496 KB |
Output is correct |
14 |
Correct |
53 ms |
7724 KB |
Output is correct |
15 |
Correct |
49 ms |
8140 KB |
Output is correct |
16 |
Correct |
42 ms |
6936 KB |
Output is correct |
17 |
Correct |
50 ms |
8104 KB |
Output is correct |
18 |
Correct |
56 ms |
8236 KB |
Output is correct |
19 |
Correct |
57 ms |
7500 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
59 ms |
8224 KB |
Output is correct |
23 |
Correct |
38 ms |
6516 KB |
Output is correct |
24 |
Correct |
59 ms |
8212 KB |
Output is correct |
25 |
Correct |
46 ms |
6828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
21 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
22 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
25 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
27 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
29 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
30 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
31 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
33 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
34 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
35 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
36 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
37 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
38 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
39 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
40 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
42 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
43 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
44 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
45 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
46 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
47 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
48 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
49 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
50 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
51 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
52 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
53 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
54 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |