Submission #755488

# Submission time Handle Problem Language Result Execution time Memory
755488 2023-06-10T07:38:39 Z drdilyor Pipes (BOI13_pipes) C++17
65 / 100
65 ms 9176 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;
    if (n != m+1) {
        if (n == m) exit(1);
        cout << 0 << '\n';
        return 0;
    }

    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 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 54 ms 7592 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 38 ms 6068 KB Output is correct
14 Correct 55 ms 7104 KB Output is correct
15 Correct 47 ms 7576 KB Output is correct
16 Correct 47 ms 6468 KB Output is correct
17 Correct 56 ms 7500 KB Output is correct
18 Correct 49 ms 7604 KB Output is correct
19 Correct 65 ms 9176 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 55 ms 7540 KB Output is correct
23 Correct 37 ms 6092 KB Output is correct
24 Correct 49 ms 7580 KB Output is correct
25 Correct 42 ms 6336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
2 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
8 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
9 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
16 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
17 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
23 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
24 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
25 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
31 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
32 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
33 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
39 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
40 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
41 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
47 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
48 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
49 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
50 Correct 0 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero