제출 #558510

#제출 시각아이디문제언어결과실행 시간메모리
558510uroskGame (IOI14_game)C++14
0 / 100
1 ms308 KiB
#include "game.h"
// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 1505
int n;
ll dsu[maxn];
ll siz[maxn];
ll root(ll x){
    while(x!=dsu[x]){
        dsu[x] = dsu[dsu[x]];
        x = dsu[x];
    }
    return x;
}
void upd(ll x,ll y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    dsu[x] = y;
    siz[y]+=siz[x];
}
void initialize(int N) {
    n = N;
    iota(dsu+1,dsu+n+1,1);
    fill(siz,siz+n+1,1);
}
int cnt = 0;
ll sum = 0;
map<pll,bool> bio;
vector<ll> w;
ll x,y;
int hasEdge(int u, int v) {
    cnt++;
    bio[{u,v}] = 1;
    bio[{v,u}] = 1;
    if(cnt==1){
        sum = u+v;
        for(ll i = 1;i<=4;i++){
            if(i==u||i==v) continue;
            w.pb(i);
        }
        x = w[0];
        y = w[1];
        return 1;
    }
    if(u+v==n*(n-1)/2-sum) return 1;
    if(cnt==n*(n-1)/2 - 1){
        if(bio[{x,y}]==0) return 1;
        return 0;
    }
    return 0;
    u++;
    v++;
    ll ru = root(u);
    ll rv = root(v);
    cerr<<"root: "<<ru-1<< " "<<rv-1<<endl;
    if(ru==rv) return 0;
    if(siz[ru]+siz[rv]==n) return 0;
    upd(u,v);
    return 1;
}
/*
4
0 1
3 0
1 2
0 2
3 1
2 3
4
0 3
1 0
0 2
3 1
1 2
2 3
4
0 3
1 0
0 2
3 1
1 2
2 3
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...