Submission #755436

# Submission time Handle Problem Language Result Execution time Memory
755436 2023-06-10T06:04:22 Z drdilyor Pipes (BOI13_pipes) C++17
0 / 100
1000 ms 131072 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 < n; 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];
        } else assert(arr[i] == 0);
    };
    dfs(dfs, 0);
    for (int i : ans) cout << i << ' ';
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Runtime error 228 ms 131072 KB Execution killed with signal 9
2 Runtime error 105 ms 131072 KB Execution killed with signal 9
3 Execution timed out 1084 ms 63076 KB Time limit exceeded
4 Execution timed out 1067 ms 8860 KB Time limit exceeded
5 Runtime error 129 ms 131072 KB Execution killed with signal 9
6 Runtime error 226 ms 131072 KB Execution killed with signal 9
7 Runtime error 102 ms 131072 KB Execution killed with signal 9
8 Runtime error 261 ms 131072 KB Execution killed with signal 9
9 Execution timed out 1079 ms 50304 KB Time limit exceeded
10 Execution timed out 1077 ms 62704 KB Time limit exceeded
11 Runtime error 321 ms 131072 KB Execution killed with signal 9
12 Runtime error 132 ms 131072 KB Execution killed with signal 9
13 Execution timed out 1066 ms 8808 KB Time limit exceeded
14 Execution timed out 1086 ms 9012 KB Time limit exceeded
15 Execution timed out 1073 ms 10368 KB Time limit exceeded
16 Execution timed out 1070 ms 7828 KB Time limit exceeded
17 Execution timed out 1072 ms 9116 KB Time limit exceeded
18 Execution timed out 1083 ms 10872 KB Time limit exceeded
19 Runtime error 414 ms 131072 KB Execution killed with signal 9
20 Runtime error 471 ms 131072 KB Execution killed with signal 9
21 Runtime error 659 ms 131072 KB Execution killed with signal 9
22 Execution timed out 1086 ms 14224 KB Time limit exceeded
23 Execution timed out 1068 ms 7856 KB Time limit exceeded
24 Execution timed out 1079 ms 10072 KB Time limit exceeded
25 Execution timed out 1084 ms 9008 KB Time limit exceeded
# 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 448 KB Execution killed with signal 6
8 Runtime error 1 ms 452 KB Execution killed with signal 6
9 Runtime error 1 ms 444 KB Execution killed with signal 6
10 Runtime error 1 ms 468 KB Execution killed with signal 6
11 Runtime error 1 ms 444 KB Execution killed with signal 6
12 Runtime error 1 ms 468 KB Execution killed with signal 6
13 Runtime error 1 ms 452 KB Execution killed with signal 6
14 Runtime error 2 ms 452 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 464 KB Execution killed with signal 6
19 Runtime error 1 ms 460 KB Execution killed with signal 6
20 Runtime error 1 ms 468 KB Execution killed with signal 6
21 Runtime error 1 ms 420 KB Execution killed with signal 6
22 Runtime error 1 ms 468 KB Execution killed with signal 6
23 Runtime error 1 ms 472 KB Execution killed with signal 6
24 Runtime error 1 ms 468 KB Execution killed with signal 6
25 Runtime error 1 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 468 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 468 KB Execution killed with signal 6
37 Runtime error 1 ms 468 KB Execution killed with signal 6
38 Runtime error 1 ms 468 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 464 KB Execution killed with signal 6
42 Runtime error 1 ms 468 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 464 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