Submission #755439

# Submission time Handle Problem Language Result Execution time Memory
755439 2023-06-10T06:07:18 Z drdilyor Pipes (BOI13_pipes) C++17
30 / 100
80 ms 10760 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    assert(n == m+1);

    vector<int> arr(n);
    for (int& i : arr) cin >> i;

    vector<vector<pair<int,int>>> adj(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;v--;
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }

    vector<int> ans(m);
    auto dfs = [&](auto& dfs, int i, int p =-1,int pei=-1) ->void {
        int c = 0;
        for (auto [e, ei]: adj[i]) {
            if (e == p) continue;
            c++;
            dfs(dfs, e, i, ei);
        }
        if (p!=-1) {
            ans[pei] = arr[i];
            arr[p] -= arr[i];
        }
    };
    dfs(dfs, 0);
    for (int i : ans) cout << i*2<< ' ';
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 60 ms 7640 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 240 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 39 ms 6172 KB Output is correct
14 Correct 47 ms 7228 KB Output is correct
15 Correct 80 ms 7760 KB Output is correct
16 Correct 51 ms 6620 KB Output is correct
17 Correct 58 ms 7676 KB Output is correct
18 Correct 59 ms 7812 KB Output is correct
19 Correct 58 ms 10760 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 52 ms 7728 KB Output is correct
23 Correct 47 ms 6156 KB Output is correct
24 Correct 67 ms 7664 KB Output is correct
25 Correct 39 ms 6436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Runtime error 1 ms 468 KB Execution killed with signal 6
5 Runtime error 1 ms 468 KB Execution killed with signal 6
6 Runtime error 1 ms 468 KB Execution killed with signal 6
7 Runtime error 1 ms 468 KB Execution killed with signal 6
8 Runtime error 1 ms 468 KB Execution killed with signal 6
9 Runtime error 1 ms 452 KB Execution killed with signal 6
10 Runtime error 1 ms 468 KB Execution killed with signal 6
11 Runtime error 1 ms 468 KB Execution killed with signal 6
12 Runtime error 1 ms 444 KB Execution killed with signal 6
13 Runtime error 1 ms 452 KB Execution killed with signal 6
14 Runtime error 1 ms 468 KB Execution killed with signal 6
15 Runtime error 1 ms 468 KB Execution killed with signal 6
16 Runtime error 1 ms 468 KB Execution killed with signal 6
17 Runtime error 1 ms 468 KB Execution killed with signal 6
18 Runtime error 1 ms 468 KB Execution killed with signal 6
19 Runtime error 1 ms 468 KB Execution killed with signal 6
20 Runtime error 1 ms 468 KB Execution killed with signal 6
21 Runtime error 1 ms 468 KB Execution killed with signal 6
22 Runtime error 1 ms 468 KB Execution killed with signal 6
23 Runtime error 1 ms 468 KB Execution killed with signal 6
24 Runtime error 1 ms 468 KB Execution killed with signal 6
25 Runtime error 2 ms 464 KB Execution killed with signal 6
26 Runtime error 1 ms 468 KB Execution killed with signal 6
27 Runtime error 1 ms 468 KB Execution killed with signal 6
28 Runtime error 1 ms 456 KB Execution killed with signal 6
29 Runtime error 1 ms 468 KB Execution killed with signal 6
30 Runtime error 1 ms 468 KB Execution killed with signal 6
31 Runtime error 1 ms 468 KB Execution killed with signal 6
32 Runtime error 1 ms 468 KB Execution killed with signal 6
33 Runtime error 1 ms 468 KB Execution killed with signal 6
34 Runtime error 1 ms 468 KB Execution killed with signal 6
35 Runtime error 1 ms 468 KB Execution killed with signal 6
36 Runtime error 1 ms 460 KB Execution killed with signal 6
37 Runtime error 1 ms 456 KB Execution killed with signal 6
38 Runtime error 1 ms 460 KB Execution killed with signal 6
39 Runtime error 1 ms 468 KB Execution killed with signal 6
40 Runtime error 1 ms 468 KB Execution killed with signal 6
41 Runtime error 1 ms 456 KB Execution killed with signal 6
42 Runtime error 1 ms 464 KB Execution killed with signal 6
43 Runtime error 1 ms 468 KB Execution killed with signal 6
44 Runtime error 1 ms 468 KB Execution killed with signal 6
45 Runtime error 1 ms 468 KB Execution killed with signal 6
46 Runtime error 1 ms 468 KB Execution killed with signal 6
47 Runtime error 1 ms 468 KB Execution killed with signal 6
48 Runtime error 1 ms 456 KB Execution killed with signal 6
49 Runtime error 1 ms 464 KB Execution killed with signal 6
50 Runtime error 1 ms 468 KB Execution killed with signal 6
51 Runtime error 1 ms 468 KB Execution killed with signal 6
52 Runtime error 1 ms 460 KB Execution killed with signal 6
53 Runtime error 1 ms 468 KB Execution killed with signal 6
54 Runtime error 1 ms 468 KB Execution killed with signal 6