Submission #136190

#TimeUsernameProblemLanguageResultExecution timeMemory
136190zoooma13Game (IOI14_game)C++14
100 / 100
546 ms16120 KiB
#include "bits/stdc++.h" #include "game.h" using namespace std; #define MAX_N 1503 int n; int par[MAX_N] ,sz[MAX_N] ,con[MAX_N][MAX_N]; void initialize(int N){ n = N; iota(par ,par+n ,0); fill(sz ,sz+n ,1); memset(con ,0 ,sizeof con); } int fnd(int u){ return par[u] = (par[u] == u ? u : fnd(par[u])); } void unn(int u ,int v){ u = fnd(u) ,v = fnd(v); par[u] = v ,sz[v] += sz[u]; for(int w=0; w<n; w++){ con[v][w] += con[u][w]; con[w][v] += con[w][u]; } } int hasEdge(int u, int v){ u = fnd(u) ,v = fnd(v); assert(u != v); con[u][v]++; con[v][u]++; if(con[u][v] == sz[u]*sz[v]){ unn(u ,v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...