Submission #445022

# Submission time Handle Problem Language Result Execution time Memory
445022 2021-07-16T09:24:33 Z zxcvbnm Pipes (BOI13_pipes) C++14
0 / 100
237 ms 36972 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxN = 1e5 + 5;
vector<int> need, curr;
vector<pair<int, int>> adj[maxN];
vector<int> in;
vector<int> ans;
void bfs(int n) {
    queue<int> q;
    vector<bool> vis(n, false);
    for(int i = 0; i < n; i++) {
        if (in[i] == 1) {
            q.push(i);
        }
    }

    while(!q.empty()) {
        int v = q.front();
        q.pop();
        vis[v] = true;

        for(auto u : adj[v]) {
            if (vis[u.first]) continue;

            ans[u.second] = (need[v] - curr[v]) * 2;
            curr[u.first] += ans[u.second] / 2;
            curr[v] += ans[u.second] / 2;

            in[u.first]--;
            if (in[u.first] == 1) {
                q.push(u.first);
            }
        }
        assert(curr[v] == need[v]);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    need.resize(n);
    curr.assign(n, 0);
    in.assign(n, 0);
    ans.assign(n, 0);
    for(int& i : need) {
        cin >> i;
    }
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back({y, i});
        adj[y].push_back({x, i});
        in[x]++;
        in[y]++;
    }

    bool even = true;
    for(int i = 0; i < n; i++) {
        if ((int) adj[i].size() % 2) {
            even = false;
            break;
        }
    }

    if (even) {
        cout << "0\n";
    } else {
        throw;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5196 KB Execution killed with signal 6
2 Runtime error 5 ms 5196 KB Execution killed with signal 6
3 Runtime error 5 ms 5324 KB Execution killed with signal 6
4 Runtime error 55 ms 16108 KB Execution killed with signal 6
5 Runtime error 4 ms 5196 KB Execution killed with signal 6
6 Runtime error 4 ms 5196 KB Execution killed with signal 6
7 Runtime error 5 ms 5196 KB Execution killed with signal 6
8 Runtime error 5 ms 5100 KB Execution killed with signal 6
9 Runtime error 5 ms 5228 KB Execution killed with signal 6
10 Runtime error 5 ms 5324 KB Execution killed with signal 6
11 Runtime error 6 ms 5324 KB Execution killed with signal 6
12 Runtime error 5 ms 5324 KB Execution killed with signal 6
13 Runtime error 46 ms 13964 KB Execution killed with signal 6
14 Runtime error 53 ms 15556 KB Execution killed with signal 6
15 Runtime error 55 ms 16136 KB Execution killed with signal 6
16 Runtime error 48 ms 14528 KB Execution killed with signal 6
17 Runtime error 59 ms 16180 KB Execution killed with signal 6
18 Runtime error 60 ms 16204 KB Execution killed with signal 6
19 Runtime error 60 ms 15044 KB Execution killed with signal 6
20 Runtime error 4 ms 5196 KB Execution killed with signal 6
21 Runtime error 5 ms 5324 KB Execution killed with signal 6
22 Runtime error 57 ms 16128 KB Execution killed with signal 6
23 Runtime error 44 ms 13968 KB Execution killed with signal 6
24 Runtime error 57 ms 16156 KB Execution killed with signal 6
25 Runtime error 51 ms 14416 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5224 KB Execution killed with signal 6
2 Runtime error 5 ms 5324 KB Execution killed with signal 6
3 Runtime error 54 ms 15276 KB Execution killed with signal 6
4 Runtime error 75 ms 15284 KB Execution killed with signal 6
5 Runtime error 68 ms 15600 KB Execution killed with signal 6
6 Runtime error 237 ms 36972 KB Execution killed with signal 6
7 Runtime error 5 ms 5196 KB Execution killed with signal 6
8 Runtime error 5 ms 5196 KB Execution killed with signal 6
9 Runtime error 5 ms 5196 KB Execution killed with signal 6
10 Runtime error 5 ms 5196 KB Execution killed with signal 6
11 Runtime error 4 ms 5196 KB Execution killed with signal 6
12 Runtime error 5 ms 5196 KB Execution killed with signal 6
13 Runtime error 5 ms 5224 KB Execution killed with signal 6
14 Runtime error 4 ms 5156 KB Execution killed with signal 6
15 Runtime error 5 ms 5196 KB Execution killed with signal 6
16 Runtime error 5 ms 5324 KB Execution killed with signal 6
17 Runtime error 5 ms 5324 KB Execution killed with signal 6
18 Runtime error 5 ms 5324 KB Execution killed with signal 6
19 Runtime error 5 ms 5324 KB Execution killed with signal 6
20 Runtime error 5 ms 5324 KB Execution killed with signal 6
21 Runtime error 5 ms 5324 KB Execution killed with signal 6
22 Runtime error 5 ms 5324 KB Execution killed with signal 6
23 Runtime error 46 ms 13516 KB Execution killed with signal 6
24 Runtime error 60 ms 15464 KB Execution killed with signal 6
25 Runtime error 53 ms 15172 KB Execution killed with signal 6
26 Runtime error 57 ms 15320 KB Execution killed with signal 6
27 Runtime error 56 ms 15044 KB Execution killed with signal 6
28 Runtime error 56 ms 15960 KB Execution killed with signal 6
29 Runtime error 176 ms 31456 KB Execution killed with signal 6
30 Runtime error 57 ms 14788 KB Execution killed with signal 6
31 Runtime error 56 ms 15160 KB Execution killed with signal 6
32 Runtime error 55 ms 15996 KB Execution killed with signal 6
33 Runtime error 58 ms 15456 KB Execution killed with signal 6
34 Runtime error 55 ms 15252 KB Execution killed with signal 6
35 Runtime error 57 ms 15240 KB Execution killed with signal 6
36 Runtime error 57 ms 15760 KB Execution killed with signal 6
37 Runtime error 218 ms 36880 KB Execution killed with signal 6
38 Runtime error 55 ms 15240 KB Execution killed with signal 6
39 Runtime error 56 ms 15996 KB Execution killed with signal 6
40 Runtime error 56 ms 15624 KB Execution killed with signal 6
41 Runtime error 62 ms 15092 KB Execution killed with signal 6
42 Runtime error 68 ms 14980 KB Execution killed with signal 6
43 Runtime error 54 ms 14960 KB Execution killed with signal 6
44 Runtime error 54 ms 15616 KB Execution killed with signal 6
45 Runtime error 166 ms 32196 KB Execution killed with signal 6
46 Runtime error 82 ms 14924 KB Execution killed with signal 6
47 Runtime error 60 ms 15628 KB Execution killed with signal 6
48 Runtime error 59 ms 15108 KB Execution killed with signal 6
49 Runtime error 53 ms 15428 KB Execution killed with signal 6
50 Runtime error 56 ms 15420 KB Execution killed with signal 6
51 Runtime error 54 ms 15556 KB Execution killed with signal 6
52 Runtime error 53 ms 15172 KB Execution killed with signal 6
53 Runtime error 186 ms 32148 KB Execution killed with signal 6
54 Runtime error 54 ms 15184 KB Execution killed with signal 6