답안 #885117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
885117 2023-12-09T03:01:15 Z 12345678 Pipes (BOI13_pipes) C++17
74.0741 / 100
148 ms 39796 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=5e5+5;
int n, m, h[nx], u, v, sz, res[nx], vs[nx], lvl[nx], f;
vector<pair<int, int>> d[nx];

void dfs(int u, int p, int idx)
{
    vs[u]=1; lvl[u]=lvl[p]+1;
    for (auto [v, id]:d[u]) 
    {
        if (v==p) continue;
        if (!vs[v]) dfs(v, u, id);
        else if ((lvl[u]-lvl[v]+1)%2==0) f=1;
    }
    if (idx==-1) return;
    res[idx]=2*h[u];
    h[p]-=h[u];
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>h[i];
    for (int i=1; i<=m; i++) cin>>u>>v, d[u].push_back({v, i}), d[v].push_back({u, i});
    dfs(1, 1, -1);
    if (m>n||f)
    {
        cout<<0;
        return 0;
    }
    for (int i=1; i<n; i++) cout<<res[i]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 19288 KB Output is correct
2 Correct 3 ms 19036 KB Output is correct
3 Correct 4 ms 19036 KB Output is correct
4 Correct 40 ms 23088 KB Output is correct
5 Correct 4 ms 19036 KB Output is correct
6 Correct 3 ms 19036 KB Output is correct
7 Correct 3 ms 19036 KB Output is correct
8 Correct 4 ms 19112 KB Output is correct
9 Correct 4 ms 19036 KB Output is correct
10 Correct 4 ms 19036 KB Output is correct
11 Correct 4 ms 19036 KB Output is correct
12 Correct 4 ms 19036 KB Output is correct
13 Correct 35 ms 22172 KB Output is correct
14 Correct 38 ms 23032 KB Output is correct
15 Correct 42 ms 23104 KB Output is correct
16 Correct 35 ms 22608 KB Output is correct
17 Correct 39 ms 23376 KB Output is correct
18 Correct 38 ms 23132 KB Output is correct
19 Correct 42 ms 26456 KB Output is correct
20 Correct 3 ms 19108 KB Output is correct
21 Correct 4 ms 19036 KB Output is correct
22 Correct 38 ms 23136 KB Output is correct
23 Correct 31 ms 22296 KB Output is correct
24 Correct 38 ms 23264 KB Output is correct
25 Correct 32 ms 22364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 19032 KB Output isn't correct
2 Incorrect 4 ms 19032 KB Output isn't correct
3 Correct 34 ms 25676 KB Output is correct
4 Correct 38 ms 28240 KB Output is correct
5 Correct 32 ms 22608 KB Output is correct
6 Correct 133 ms 39252 KB Output is correct
7 Incorrect 3 ms 19036 KB Output isn't correct
8 Incorrect 3 ms 19036 KB Output isn't correct
9 Correct 3 ms 19036 KB Output is correct
10 Correct 3 ms 19036 KB Output is correct
11 Correct 3 ms 19036 KB Output is correct
12 Correct 4 ms 19544 KB Output is correct
13 Correct 3 ms 19032 KB Output is correct
14 Incorrect 3 ms 19036 KB Output isn't correct
15 Incorrect 4 ms 19036 KB Output isn't correct
16 Incorrect 4 ms 19036 KB Output isn't correct
17 Correct 4 ms 19036 KB Output is correct
18 Correct 4 ms 19036 KB Output is correct
19 Correct 3 ms 19036 KB Output is correct
20 Correct 4 ms 19036 KB Output is correct
21 Correct 4 ms 19036 KB Output is correct
22 Incorrect 4 ms 19196 KB Output isn't correct
23 Incorrect 35 ms 26112 KB Output isn't correct
24 Incorrect 42 ms 26892 KB Output isn't correct
25 Correct 36 ms 25624 KB Output is correct
26 Correct 40 ms 27484 KB Output is correct
27 Correct 37 ms 27812 KB Output is correct
28 Correct 34 ms 22588 KB Output is correct
29 Correct 110 ms 36440 KB Output is correct
30 Incorrect 44 ms 29364 KB Output isn't correct
31 Incorrect 43 ms 29520 KB Output isn't correct
32 Incorrect 40 ms 24404 KB Output isn't correct
33 Correct 35 ms 26712 KB Output is correct
34 Correct 36 ms 26704 KB Output is correct
35 Correct 39 ms 28240 KB Output is correct
36 Correct 32 ms 22608 KB Output is correct
37 Correct 148 ms 39796 KB Output is correct
38 Incorrect 45 ms 28496 KB Output isn't correct
39 Incorrect 39 ms 23824 KB Output isn't correct
40 Incorrect 42 ms 26708 KB Output isn't correct
41 Correct 37 ms 29004 KB Output is correct
42 Correct 36 ms 26964 KB Output is correct
43 Correct 37 ms 28496 KB Output is correct
44 Correct 33 ms 22620 KB Output is correct
45 Correct 100 ms 34900 KB Output is correct
46 Incorrect 43 ms 30032 KB Output isn't correct
47 Incorrect 41 ms 26852 KB Output isn't correct
48 Incorrect 44 ms 29272 KB Output isn't correct
49 Correct 32 ms 23456 KB Output is correct
50 Correct 35 ms 26708 KB Output is correct
51 Correct 35 ms 24912 KB Output is correct
52 Correct 34 ms 24156 KB Output is correct
53 Correct 108 ms 35692 KB Output is correct
54 Incorrect 56 ms 27984 KB Output isn't correct