Submission #72615

#TimeUsernameProblemLanguageResultExecution timeMemory
72615vexGame (IOI14_game)C++14
15 / 100
4 ms1188 KiB
#include <bits/stdc++.h> #define maxn 1505 using namespace std; int n; int sz[maxn],p[maxn],br[maxn][maxn]; void initialize(int N) { n=N; for(int i=0;i<n;i++) { sz[i]=1; p[i]=i; } for(int i=0;i<n;i++)for(int j=0;j<n;j++)br[i][j]=0; } int fnd(int x) { if(x==p[x])return x; return p[x]=fnd(p[x]); } int hasEdge(int u,int v) { u=fnd(u); v=fnd(v); if(u==v)return 1; if(sz[u]<sz[v])swap(u,v); if(br[u][v]+1==sz[u]*sz[v]) { sz[u]+=sz[v]; p[v]=p[u]; for(int i=0;i<n-1;i++) { if(i==u)continue; br[u][i]+=br[v][i]; br[i][u]+=br[v][i]; } return 1; } br[u][v]++; br[v][u]++; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...