Submission #385418

#TimeUsernameProblemLanguageResultExecution timeMemory
385418alishahali1382Game (IOI14_game)C++14
100 / 100
501 ms20460 KiB
#include "game.h" #include <bits/stdc++.h> const int MAXN=1510; int n, x, y; int par[MAXN]; int deg[MAXN][MAXN]; int getpar(int x){ return (par[x]==x?x:par[x]=getpar(par[x]));} void initialize(int nn){ n=nn; for (int i=0; i<n; i++){ par[i]=i; for (int j=0; j<n; j++) deg[i][j]=(i!=j); } } int hasEdge(int u, int v){ x=getpar(u); y=getpar(v); assert(x!=y); deg[x][y]--; deg[y][x]--; if (deg[x][y]) return 0; for (int i=0; i<n; i++){ deg[i][y]+=deg[i][x]; deg[i][x]=0; deg[y][i]+=deg[x][i]; deg[x][i]=0; } par[x]=y; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...