답안 #546849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546849 2022-04-08T16:24:41 Z neki 낙하산 고리들 (IOI12_rings) C++14
0 / 100
330 ms 39244 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;
                if(kok3==cnt[3])++br;
            }
            
            ans=br;
        }
        else ans=0;
    }
    else add(a, b);
}

int CountCritical(){return ans;}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 280 ms 32916 KB Output is correct
2 Incorrect 330 ms 39244 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -