제출 #291388

#제출 시각아이디문제언어결과실행 시간메모리
291388TMJN게임 (IOI14_game)C++17
100 / 100
563 ms25368 KiB
#include "game.h" int N; int C[1500][1500]; int T[1500]; int par(int x){ if(T[x]<0)return x; return T[x]=par(T[x]); } void uni(int x,int y){ x=par(x); y=par(y); if(x==y)return; T[x]+=T[y]; T[y]=x; for(int i=0;i<N;i++){ C[i][x]+=C[i][y]; } for(int i=0;i<N;i++){ C[x][i]+=C[y][i]; } } void initialize(int n) { N=n; for(int i=0;i<N;i++){ T[i]=-1; } } int hasEdge(int u, int v) { u=par(u); v=par(v); if(C[u][v]==T[u]*T[v]-1){ uni(u,v); return 1; } else{ C[u][v]++; C[v][u]++; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...