Submission #742017

# Submission time Handle Problem Language Result Execution time Memory
742017 2023-05-15T11:37:10 Z irmuun Pipes (BOI13_pipes) C++17
30 / 100
423 ms 130488 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    map<pair<ll,ll>,ll>mp;
    set<ll>s[n+5];
    ll c[n+5],p[n+5];
    fill(p,p+n+1,0);
    for(ll i=1;i<=n;i++){
        cin>>c[i];
    }
    vector<pair<ll,ll>>edge;
    for(ll i=1;i<=m;i++){
        ll u,v;
        cin>>u>>v;
        edge.pb({u,v});
        s[u].insert(v);
        s[v].insert(u);
        p[u]++;
        p[v]++;
    }
    queue<ll>q;
    for(ll i=1;i<=n;i++){
        if(p[i]==1){
            q.push(i);
        }
    }
    for(ll i=1;i<n;i++){
        ll x=q.front();
        q.pop();
        if(p[x]==0){
            continue;
        }
        ll y=*s[x].begin();
        mp[{x,y}]=2*c[x];
        c[y]-=c[x];
        p[y]--;
        p[x]--;
        s[x].erase(y);
        s[y].erase(x);
        if(p[y]==1){
            q.push(y);
        }
    }
    if(c[q.front()]!=0){
        cout<<0;
        return 0;
    }
    for(auto [u,v]:edge){
        cout<<mp[{u,v}]+mp[{v,u}]<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 198 ms 23124 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 2 ms 584 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 163 ms 18488 KB Output is correct
14 Correct 180 ms 21904 KB Output is correct
15 Correct 199 ms 23184 KB Output is correct
16 Correct 156 ms 19752 KB Output is correct
17 Correct 197 ms 23072 KB Output is correct
18 Correct 203 ms 23200 KB Output is correct
19 Correct 203 ms 23184 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 234 ms 23200 KB Output is correct
23 Correct 150 ms 18468 KB Output is correct
24 Correct 225 ms 23172 KB Output is correct
25 Correct 160 ms 19408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 11
2 Runtime error 1 ms 724 KB Execution killed with signal 11
3 Runtime error 90 ms 35336 KB Execution killed with signal 11
4 Runtime error 79 ms 37200 KB Execution killed with signal 11
5 Runtime error 114 ms 36716 KB Execution killed with signal 11
6 Runtime error 423 ms 130484 KB Execution killed with signal 11
7 Runtime error 1 ms 468 KB Execution killed with signal 11
8 Incorrect 0 ms 340 KB Output isn't correct
9 Runtime error 1 ms 468 KB Execution killed with signal 11
10 Runtime error 1 ms 444 KB Execution killed with signal 11
11 Runtime error 1 ms 468 KB Execution killed with signal 11
12 Runtime error 1 ms 468 KB Execution killed with signal 11
13 Runtime error 1 ms 468 KB Execution killed with signal 11
14 Incorrect 1 ms 340 KB Output isn't correct
15 Runtime error 1 ms 724 KB Execution killed with signal 11
16 Runtime error 2 ms 840 KB Execution killed with signal 11
17 Runtime error 1 ms 852 KB Execution killed with signal 11
18 Runtime error 1 ms 840 KB Execution killed with signal 11
19 Runtime error 1 ms 724 KB Execution killed with signal 11
20 Runtime error 2 ms 852 KB Execution killed with signal 11
21 Runtime error 2 ms 1136 KB Execution killed with signal 11
22 Runtime error 2 ms 852 KB Execution killed with signal 11
23 Runtime error 66 ms 30384 KB Execution killed with signal 11
24 Runtime error 95 ms 37432 KB Execution killed with signal 11
25 Runtime error 100 ms 35332 KB Execution killed with signal 11
26 Runtime error 80 ms 37228 KB Execution killed with signal 11
27 Runtime error 74 ms 36828 KB Execution killed with signal 11
28 Runtime error 123 ms 38748 KB Execution killed with signal 11
29 Runtime error 323 ms 107124 KB Execution killed with signal 11
30 Runtime error 108 ms 36456 KB Execution killed with signal 6
31 Runtime error 93 ms 37168 KB Execution killed with signal 11
32 Runtime error 151 ms 37684 KB Execution killed with signal 11
33 Runtime error 111 ms 37432 KB Execution killed with signal 11
34 Runtime error 80 ms 37180 KB Execution killed with signal 11
35 Runtime error 94 ms 37208 KB Execution killed with signal 11
36 Runtime error 106 ms 37808 KB Execution killed with signal 11
37 Runtime error 382 ms 130488 KB Execution killed with signal 11
38 Runtime error 116 ms 37216 KB Execution killed with signal 6
39 Runtime error 120 ms 37576 KB Execution killed with signal 11
40 Runtime error 100 ms 37780 KB Execution killed with signal 11
41 Runtime error 70 ms 37176 KB Execution killed with signal 11
42 Runtime error 68 ms 37244 KB Execution killed with signal 11
43 Runtime error 64 ms 37168 KB Execution killed with signal 11
44 Runtime error 128 ms 36736 KB Execution killed with signal 11
45 Runtime error 405 ms 110764 KB Execution killed with signal 11
46 Runtime error 103 ms 36916 KB Execution killed with signal 11
47 Runtime error 104 ms 37684 KB Execution killed with signal 11
48 Runtime error 73 ms 37296 KB Execution killed with signal 11
49 Runtime error 111 ms 35640 KB Execution killed with signal 11
50 Runtime error 93 ms 37312 KB Execution killed with signal 11
51 Runtime error 97 ms 37712 KB Execution killed with signal 11
52 Runtime error 82 ms 36668 KB Execution killed with signal 11
53 Runtime error 401 ms 114952 KB Execution killed with signal 11
54 Runtime error 107 ms 36704 KB Execution killed with signal 6