제출 #226999

#제출 시각아이디문제언어결과실행 시간메모리
226999Charis02게임 (IOI14_game)C++14
0 / 100
4 ms384 KiB
#include "game.h" #define N 1505 int par[N],edges[N][N],nn; int f(int x) { if(par[x]==x) return x; return par[x]=f(par[x]); } bool issameset(int x,int y) { int fx=f(x); int fy = f(y); return (fx==fy); } void join(int x,int y) { int fx = f(x); int fy = f(y); par[fx] = fy; for(int i = 0;i < nn;i++) { edges[fy][i] += edges[fx][i]; edges[fx][i] = 0; } return; } void initialize(int n) { nn = n; for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { if(i==j) continue; edges[i][j]=1; } par[i]=i; } return; } int hasEdge(int u, int v) { if(issameset(u,v)) return 0; int fu = f(u); int fv = f(v); edges[fu][fv]--; edges[fv][fu]--; if(edges[fu][fv] == 0) { join(fu,fv); return 1; } else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...