Submission #546852

# Submission time Handle Problem Language Result Execution time Memory
546852 2022-04-08T16:29:28 Z neki Parachute rings (IOI12_rings) C++14
0 / 100
328 ms 39304 KB
#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 500100
#define par pair<ll, ll>
#define ld long double
#define mod 1000000007
 
int n, mm=0, cent=-1, ans;
vc<vc<int>> edg;
vc<int> cnt;
 
void Init(int N){
    int n=N;
    
    ans=n;
    edg.resize(n);
    cnt.resize(n+1, 0);cnt[0]=n;
    loop(i, 0, n) cnt.ps(i);
}
 
void add(int a, int b){
    --cnt[edg[a].size()];
    --cnt[edg[b].size()];
    edg[a].ps(b);
    edg[b].ps(a);
    ++cnt[edg[a].size()];
    ++cnt[edg[b].size()];
}

void Link(int a, int b){
    if(edg[a].size()<edg[b].size()) swap(a, b);
    
    if(ans==0) return;
    
    if(edg[a].size()>=3 and edg[b].size()>=3)ans=0;
    else if(edg[a].size()>=3){
        if(cent==a) add(a, b);
        else if(cent==-1){
            cent=a;
            
            add(a, b);
            
            int kok3za=0;
            fore(v, edg[a]) if(edg[v].size()==3) ++kok3za;
            
            ans=(kok3za==cnt[3]);
        }
        else ans=0;
    }
    else if(edg[a].size()==2){
        add(a, b);
        
        if(cnt[3]<=4){
            ll br=0;
            loop(i, 0, n){
                ll kok3=(edg[i].size()==3);
                fore(v, edg[i]) if(edg[v].size()==3) ++kok3;
                br+=(kok3==cnt[3]);
            }
            
            ans=br;
        }
        else ans=0;
    }
    else add(a, b);
}
 
int CountCritical(){return ans;}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 265 ms 32860 KB Output is correct
2 Incorrect 328 ms 39304 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -