Submission #1275976

#TimeUsernameProblemLanguageResultExecution timeMemory
1275976avohadoGame (IOI14_game)C++20
100 / 100
242 ms15792 KiB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
#define mod 1000000007
#define maxn 200005
#define f first
#define s second
#define ll long long
#define pb(x) push_back(x)
int t[1501][1501], p[1501], n1;
void initialize(int n){
    n1=n;
    for(int i=1; i<=n; i++){
        p[i]=i;
        for(int j=1; j<=n; j++){
            t[i][j]=i!=j;
        }
    }
}
int bck(int u){
    if(p[u]==u){
        return u;
    }
    p[u]=bck(p[u]);
    return p[u];
}
int hasEdge(int u, int v){
    u++;v++;
    if(bck(u)>bck(v)){
        swap(u, v);
    }
    if(t[p[u]][p[v]]>1){
        t[p[u]][p[v]]--;
        t[p[v]][p[u]]--;
        return 0;
    }else{
        t[p[u]][p[v]]--;
        t[p[v]][p[u]]--;
        for(int i=1; i<=n1; i++){
            t[p[u]][i]+=t[p[v]][i];
            t[i][p[u]]+=t[p[v]][i];
        }
        p[p[v]]=p[u];
        return 1;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...