제출 #120452

#제출 시각아이디문제언어결과실행 시간메모리
120452anayk게임 (IOI14_game)C++14
0 / 100
2 ms412 KiB
#include <iostream> #define MAXN 2000 int N; int cross[MAXN][MAXN]; int par[MAXN]; int root(int u) { if(par[u] < 0) return u; par[u] = root(par[u]); return par[u]; } void merge(int u, int v) { if(par[u] > par[v]) u ^= v ^= u ^= v; par[u] += par[v]; par[v] = u; for(int i = 0; i < N; i++) { cross[u][i] += cross[v][i]; cross[i][u] = cross[u][i]; } } void initialize(int n) { N = n; for(int i = 0; i < N; i++) par[i] = -1; } int hasEdge(int u, int v) { int x = root(u); int y = root(v); if(cross[x][y] + 1 == par[x]*par[y]) { merge(x, y); return 1; } else { cross[x][y]++; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...