Submission #783875

#TimeUsernameProblemLanguageResultExecution timeMemory
783875FatihSolakGame (IOI14_game)C++17
0 / 100
1 ms256 KiB
#include "game.h"
#include <bits/stdc++.h>
#define N 1500
using namespace std;
int par[N];
int cnt[N][N];
int find(int a){
    if(a == par[a])return a;
    return par[a] = find(par[a]);
}
int n;
void initialize(int n){
    ::n = n;
    for(int i = 0;i<n;i++){
        par[i] = i;
        for(int j = 0;j<n;j++){
            cnt[i][j] = i != j;
        }
    }
}

int hasEdge(int u, int v){
    int tot = cnt[find(u)][find(v)];
    cnt[find(u)][find(v)]--;
    cnt[find(v)][find(u)]--;
    if(tot > 1){
        return 0;
    }
    for(int i = 0;i<n;i++){
        cnt[find(u)][find(i)] += cnt[find(v)][find(i)];
    }
    par[find(v)] = find(u);
    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...