제출 #745597

#제출 시각아이디문제언어결과실행 시간메모리
745597Username4132게임 (IOI14_game)C++14
100 / 100
409 ms25316 KiB
#include "game.h" #include<iostream> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) const int MAXN=1510; int n, number[MAXN][MAXN], par[MAXN], si[MAXN]; int root(int a){ while(par[a]!=a) a=par[a]=par[par[a]]; return a; } void initialize(int N) { n=N; forn(i, n) par[i]=i, si[i]=1; } int hasEdge(int a, int b){ int ra=root(a), rb=root(b); if(ra==rb) return 0; if(si[ra]<si[rb]) swap(ra, rb); if(si[ra]*si[rb]-1 == number[ra][rb]){ forn(i, n) number[i][ra]+=number[i][rb]; forn(i, n) number[ra][i]+=number[rb][i]; si[ra]+=si[rb]; par[rb]=ra; return 1; } else{ number[ra][rb]++; number[rb][ra]++; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...