제출 #8590

#제출 시각아이디문제언어결과실행 시간메모리
8590cki86201게임 (IOI14_game)C++98
100 / 100
532 ms18700 KiB
#include "game.h" #define N_ 1502 int N; struct unf{ int p[N_], c[N_]; int w[N_][N_]; void init(){for(int i=0;i<N;i++)p[i] = i, c[i] = 1;} int Find(int x){return p[x] == x ? x : p[x] = Find(p[x]);} int Union(int x,int y){ x = Find(x), y = Find(y); if(w[x][y] == c[x] * c[y] - 1){ p[x] = y, c[y] += c[x]; for(int i=0;i<N;i++)w[y][i] += w[x][i], w[i][y] += w[i][x]; return 1; } w[x][y]++, w[y][x]++; return 0; } }uf; void initialize(int n) { N = n; uf.init(); } int hasEdge(int u, int v) { return uf.Union(u,v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...