Submission #677758

# Submission time Handle Problem Language Result Execution time Memory
677758 2023-01-04T10:03:38 Z dooompy Pipes (BOI13_pipes) C++17
72.7778 / 100
1000 ms 17740 KB
#include "bits/stdc++.h"

using namespace std;

void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}

#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif

using ll = long long;

ll v[100005];
int deg[100005];

vector<pair<int, int>> adj[100005];
ll calc[500005];

bool seen[100005];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);
    int n, m; cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> v[i];
    for (int i = 1; i <= m; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back({b, i});
        adj[b].push_back({a, i});
        deg[a]++; deg[b]++;
    }

    queue<int> q;

    for (int i = 1; i <= n; i++) {
        if (deg[i] == 1) {
            q.push(i);
        }
    }

    while (!q.empty()) {
        // deg 1
        auto cur = q.front(); q.pop();
        seen[cur] = true;
        deg[cur] = 0;

        for (auto to : adj[cur]) {
            if (seen[to.first]) continue;
            ll weight = v[cur];

            v[to.first] -= weight;
            calc[to.second] = weight;

            if (--deg[to.first] == 1) {
                q.push(to.first);
            }
        }
    }

    if (m == n - 1) {
        for (int i = 1; i <= m; i++) {
            cout << calc[i] * 2 << "\n";
        }
        return 0;
    }

    if (m > n || m % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; i++) {
        while (true) {}
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 51 ms 9084 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 40 ms 7724 KB Output is correct
14 Correct 48 ms 8652 KB Output is correct
15 Correct 59 ms 9036 KB Output is correct
16 Correct 47 ms 8160 KB Output is correct
17 Correct 55 ms 9060 KB Output is correct
18 Correct 52 ms 9120 KB Output is correct
19 Correct 51 ms 8336 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 58 ms 9044 KB Output is correct
23 Correct 42 ms 7764 KB Output is correct
24 Correct 54 ms 9064 KB Output is correct
25 Correct 41 ms 7944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Incorrect 2 ms 2644 KB Output isn't correct
3 Correct 38 ms 8004 KB Output is correct
4 Correct 52 ms 7952 KB Output is correct
5 Correct 41 ms 8308 KB Output is correct
6 Correct 148 ms 17732 KB Output is correct
7 Incorrect 1 ms 2644 KB Output isn't correct
8 Execution timed out 1080 ms 2644 KB Time limit exceeded
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Incorrect 2 ms 2644 KB Output isn't correct
15 Incorrect 2 ms 2644 KB Output isn't correct
16 Execution timed out 1084 ms 2644 KB Time limit exceeded
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Incorrect 2 ms 2644 KB Output isn't correct
23 Execution timed out 1091 ms 7024 KB Time limit exceeded
24 Incorrect 43 ms 8200 KB Output isn't correct
25 Correct 39 ms 7944 KB Output is correct
26 Correct 41 ms 8080 KB Output is correct
27 Correct 37 ms 7920 KB Output is correct
28 Correct 40 ms 8500 KB Output is correct
29 Correct 125 ms 15564 KB Output is correct
30 Incorrect 51 ms 7760 KB Output isn't correct
31 Execution timed out 1088 ms 7920 KB Time limit exceeded
32 Execution timed out 1088 ms 8492 KB Time limit exceeded
33 Correct 42 ms 8152 KB Output is correct
34 Correct 37 ms 7884 KB Output is correct
35 Correct 38 ms 8016 KB Output is correct
36 Correct 47 ms 8288 KB Output is correct
37 Correct 143 ms 17740 KB Output is correct
38 Incorrect 42 ms 7932 KB Output isn't correct
39 Execution timed out 1092 ms 8484 KB Time limit exceeded
40 Incorrect 42 ms 8268 KB Output isn't correct
41 Execution timed out 1088 ms 8012 KB Time limit exceeded
42 Correct 47 ms 7744 KB Output is correct
43 Correct 34 ms 7828 KB Output is correct
44 Correct 47 ms 8348 KB Output is correct
45 Correct 110 ms 15540 KB Output is correct
46 Incorrect 42 ms 7756 KB Output isn't correct
47 Incorrect 41 ms 8268 KB Output isn't correct
48 Execution timed out 1093 ms 7900 KB Time limit exceeded
49 Correct 38 ms 8268 KB Output is correct
50 Correct 40 ms 8144 KB Output is correct
51 Correct 40 ms 8272 KB Output is correct
52 Correct 43 ms 7920 KB Output is correct
53 Correct 132 ms 15480 KB Output is correct
54 Incorrect 41 ms 8004 KB Output isn't correct