제출 #1225923

#제출 시각아이디문제언어결과실행 시간메모리
1225923kl0989e게임 (IOI14_game)C++20
0 / 100
0 ms328 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()

const int maxn=1510;

int n;

vi head(maxn);
vi emptyneig(maxn);

int get(int a) {
    return (a==head[a]?a:head[a]=get(head[a]));
}

void initialize(int _n) {
    n=_n;
    iota(all(head),0);
    fill(all(emptyneig),n-1);
}

int hasEdge(int u, int v) {
    int hu=get(u);
    int hv=get(v);
    if (hu==hv) {
        return 0;
    }
    emptyneig[hu]--;
    emptyneig[hv]--;
    if (emptyneig[hu]==0 || emptyneig[hv]==0) {
        head[hu]=hv;
        emptyneig[hv]+=emptyneig[hu];
        return 1;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...