답안 #546837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546837 2022-04-08T16:16:49 Z neki 낙하산 고리들 (IOI12_rings) C++14
0 / 100
646 ms 76160 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);
    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]==1) ans=4;
        else if(cnt[3]<=4){
            ll br=0;
            loop(i, 0, n) if(edg[i].size()==3){
                ll kok3=0;
                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 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 39736 KB Output is correct
2 Correct 519 ms 61068 KB Output is correct
3 Correct 354 ms 44652 KB Output is correct
4 Incorrect 646 ms 76160 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -