Submission #445023

# Submission time Handle Problem Language Result Execution time Memory
445023 2021-07-16T09:26:00 Z zxcvbnm Pipes (BOI13_pipes) C++14
44.0741 / 100
207 ms 18056 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 {
        cout << "0\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Incorrect 2 ms 2636 KB Output isn't correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Incorrect 46 ms 7868 KB Output isn't correct
5 Incorrect 2 ms 2636 KB Output isn't correct
6 Incorrect 2 ms 2636 KB Output isn't correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Incorrect 2 ms 2628 KB Output isn't correct
9 Incorrect 2 ms 2636 KB Output isn't correct
10 Incorrect 2 ms 2636 KB Output isn't correct
11 Incorrect 2 ms 2636 KB Output isn't correct
12 Incorrect 2 ms 2636 KB Output isn't correct
13 Incorrect 40 ms 6980 KB Output isn't correct
14 Incorrect 44 ms 7604 KB Output isn't correct
15 Incorrect 47 ms 7860 KB Output isn't correct
16 Incorrect 40 ms 7060 KB Output isn't correct
17 Incorrect 46 ms 7956 KB Output isn't correct
18 Incorrect 48 ms 7964 KB Output isn't correct
19 Incorrect 46 ms 7368 KB Output isn't correct
20 Incorrect 2 ms 2636 KB Output isn't correct
21 Incorrect 2 ms 2636 KB Output isn't correct
22 Incorrect 47 ms 7956 KB Output isn't correct
23 Incorrect 38 ms 6856 KB Output isn't correct
24 Incorrect 48 ms 7972 KB Output isn't correct
25 Incorrect 38 ms 7016 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Incorrect 2 ms 2636 KB Output isn't correct
3 Correct 43 ms 7316 KB Output is correct
4 Correct 45 ms 7496 KB Output is correct
5 Correct 46 ms 7668 KB Output is correct
6 Correct 207 ms 18056 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Incorrect 2 ms 2636 KB Output isn't correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Incorrect 2 ms 2636 KB Output isn't correct
15 Incorrect 2 ms 2636 KB Output isn't correct
16 Incorrect 2 ms 2600 KB Output isn't correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Incorrect 2 ms 2636 KB Output isn't correct
23 Incorrect 39 ms 6636 KB Output isn't correct
24 Incorrect 54 ms 7592 KB Output isn't correct
25 Correct 46 ms 7364 KB Output is correct
26 Correct 47 ms 7492 KB Output is correct
27 Correct 45 ms 7368 KB Output is correct
28 Correct 52 ms 7752 KB Output is correct
29 Correct 163 ms 15648 KB Output is correct
30 Incorrect 45 ms 7228 KB Output isn't correct
31 Incorrect 47 ms 7308 KB Output isn't correct
32 Incorrect 47 ms 7864 KB Output isn't correct
33 Correct 48 ms 7560 KB Output is correct
34 Correct 50 ms 7472 KB Output is correct
35 Correct 47 ms 7492 KB Output is correct
36 Correct 51 ms 7660 KB Output is correct
37 Correct 190 ms 17964 KB Output is correct
38 Incorrect 53 ms 7492 KB Output isn't correct
39 Incorrect 46 ms 7804 KB Output isn't correct
40 Incorrect 47 ms 7576 KB Output isn't correct
41 Correct 49 ms 7320 KB Output is correct
42 Correct 47 ms 7260 KB Output is correct
43 Correct 45 ms 7292 KB Output is correct
44 Correct 52 ms 7792 KB Output is correct
45 Correct 162 ms 15740 KB Output is correct
46 Incorrect 45 ms 7340 KB Output isn't correct
47 Incorrect 48 ms 7532 KB Output isn't correct
48 Incorrect 46 ms 7352 KB Output isn't correct
49 Correct 45 ms 7560 KB Output is correct
50 Correct 49 ms 7500 KB Output is correct
51 Correct 48 ms 7620 KB Output is correct
52 Correct 46 ms 7420 KB Output is correct
53 Correct 172 ms 15704 KB Output is correct
54 Incorrect 47 ms 7376 KB Output isn't correct