Submission #710794

# Submission time Handle Problem Language Result Execution time Memory
710794 2023-03-15T20:17:12 Z pls33 Pipes (BOI13_pipes) C++17
0 / 100
237 ms 26444 KB
// boi2013 d1p3
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma region dalykai
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;
using f80 = long double;
#pragma endregion

int main()
{
#ifndef _AAAAAAAAA
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#else
    freopen("pipes.in", "r", stdin);
#ifndef __linux__
    atexit([]()
           {
        freopen("con", "r", stdin);
        system("pause"); });
#endif
#endif

    int v, e;
    cin >> v >> e;

    vi32 initial(v);
    for (auto &i : initial)
    {
        cin >> i;
    }

    vvp32 adj(v);
    vi32 degree(v);
    for (int i = 0; i < e; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        adj[a].emplace_back(b, i);
        adj[b].emplace_back(a, i);
        degree[a]++;
        degree[b]++;
    }

    // kadangi jungus grafas, pirma atmetam visas medzio dalis ir po to jei lieka
    // nelyginis ciklas (is 2k+1 virsuniu), tai sutvarkom ji
    // jei lieka kazkoks keistas darinys, tai isvedam 0

    queue<int> q;
    for (int i = 0; i < v; i++)
    {
        if (degree[i] == 1)
        {
            q.push(i);
        }
    }

    vi32 fill(e);
    while (!q.empty())
    {
        int cur = q.front();
        q.pop();

        for (auto &[next, edge] : adj[cur])
        {
            fill[edge] += initial[cur];
            initial[next] -= initial[cur];
            degree[next]--;

            if (degree[next] == 1)
            {
                q.push(next);
            }
        }

        degree[cur] = max(0, degree[cur] - 1);
    }

    for (auto &f : fill)
    {
        cout << f * 2 << '\n';
    }

    return 0;
}

Compilation message

pipes.cpp:9: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
    9 | #pragma region dalykai
      | 
pipes.cpp:33: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   33 | #pragma endregion
      |
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Incorrect 70 ms 9716 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Incorrect 1 ms 340 KB Output isn't correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Incorrect 42 ms 7848 KB Output isn't correct
14 Incorrect 51 ms 9244 KB Output isn't correct
15 Incorrect 58 ms 9776 KB Output isn't correct
16 Incorrect 45 ms 8384 KB Output isn't correct
17 Incorrect 62 ms 9788 KB Output isn't correct
18 Incorrect 53 ms 9852 KB Output isn't correct
19 Incorrect 55 ms 9036 KB Output isn't correct
20 Incorrect 0 ms 324 KB Output isn't correct
21 Incorrect 1 ms 340 KB Output isn't correct
22 Incorrect 63 ms 9840 KB Output isn't correct
23 Incorrect 54 ms 7756 KB Output isn't correct
24 Incorrect 63 ms 9832 KB Output isn't correct
25 Incorrect 47 ms 8200 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 51 ms 8764 KB Output isn't correct
4 Incorrect 54 ms 8908 KB Output isn't correct
5 Incorrect 67 ms 9336 KB Output isn't correct
6 Incorrect 206 ms 26404 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 1 ms 324 KB Output isn't correct
10 Incorrect 1 ms 212 KB Output isn't correct
11 Incorrect 1 ms 340 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Incorrect 1 ms 324 KB Output isn't correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Incorrect 1 ms 332 KB Output isn't correct
17 Incorrect 1 ms 340 KB Output isn't correct
18 Incorrect 1 ms 340 KB Output isn't correct
19 Incorrect 1 ms 336 KB Output isn't correct
20 Incorrect 1 ms 332 KB Output isn't correct
21 Incorrect 2 ms 468 KB Output isn't correct
22 Incorrect 1 ms 332 KB Output isn't correct
23 Incorrect 39 ms 7480 KB Output isn't correct
24 Incorrect 61 ms 9164 KB Output isn't correct
25 Incorrect 59 ms 8772 KB Output isn't correct
26 Incorrect 53 ms 8940 KB Output isn't correct
27 Incorrect 48 ms 8668 KB Output isn't correct
28 Incorrect 50 ms 9568 KB Output isn't correct
29 Incorrect 157 ms 22088 KB Output isn't correct
30 Incorrect 53 ms 8708 KB Output isn't correct
31 Incorrect 46 ms 8888 KB Output isn't correct
32 Incorrect 49 ms 9568 KB Output isn't correct
33 Incorrect 50 ms 9164 KB Output isn't correct
34 Incorrect 47 ms 8924 KB Output isn't correct
35 Incorrect 48 ms 8908 KB Output isn't correct
36 Incorrect 55 ms 9448 KB Output isn't correct
37 Incorrect 237 ms 26444 KB Output isn't correct
38 Incorrect 48 ms 8992 KB Output isn't correct
39 Incorrect 51 ms 9532 KB Output isn't correct
40 Incorrect 51 ms 9236 KB Output isn't correct
41 Incorrect 47 ms 8860 KB Output isn't correct
42 Incorrect 53 ms 8740 KB Output isn't correct
43 Incorrect 55 ms 8700 KB Output isn't correct
44 Incorrect 50 ms 9272 KB Output isn't correct
45 Incorrect 152 ms 22124 KB Output isn't correct
46 Incorrect 56 ms 8908 KB Output isn't correct
47 Incorrect 57 ms 9300 KB Output isn't correct
48 Incorrect 51 ms 8916 KB Output isn't correct
49 Incorrect 49 ms 9072 KB Output isn't correct
50 Incorrect 48 ms 9036 KB Output isn't correct
51 Incorrect 55 ms 9292 KB Output isn't correct
52 Incorrect 61 ms 8780 KB Output isn't correct
53 Incorrect 185 ms 22732 KB Output isn't correct
54 Incorrect 48 ms 8996 KB Output isn't correct