Submission #1207332

#TimeUsernameProblemLanguageResultExecution timeMemory
1207332candi_ositosGame (IOI14_game)C++20
0 / 100
0 ms328 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> p;
vector <int> joke;
int N;
void initialize(int n)
{
    N=n;
    joke.assign(n, n-1);
    p.resize(n);
    for(int i=0; i<n; ++i)
    {
        p[i]=i;
    }
}
int fgp(int a)
{
    if(p[a]==a)
    {
        return a;
    }
    return p[a]=fgp(p[a]);
}
int hasEdge(int u, int v)
{
    if(fgp(u)==fgp(v))
    {
        return 1;
    }
    if(joke[fgp(u)]<=1 || joke[fgp(v)]<=1)
    {
        --joke[fgp(v)];
        --joke[fgp(u)];
        joke[fgp(v)]=max(joke[fgp(u)], joke[fgp(v)]);
        p[fgp(u)]=fgp(v);
        return 1;
    }
    --joke[fgp(u)];
    --joke[fgp(v)];
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...