제출 #1059023

#제출 시각아이디문제언어결과실행 시간메모리
1059023oscarsierra12게임 (IOI14_game)C++14
100 / 100
205 ms26596 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1510; int fat[N], sz[N]; int nedges[N][N]; int nn = 0; void ini(int n) { for (int i = 0; i < n; ++i) fat[i] = i, sz[i] = 1; } int fnd (int x) { if (x == fat[x]) return x; return fat[x] = fnd(fat[x]); } void uni (int x, int y) { int fx = fnd(x), fy = fnd(y); fat[fx] = fy; sz[fy] += sz[fx]; for (int z = 0; z < nn; ++z) { nedges[fy][z] += nedges[fx][z]; nedges[z][fy] += nedges[z][fx]; } } void initialize(int n) { nn = n; ini(n); } int hasEdge(int u, int v) { if (nedges[fnd(u)][fnd(v)] == sz[fnd(u)] * sz[fnd(v)] - 1) { uni(u, v); return 1; } nedges[fnd(u)][fnd(v)]++; nedges[fnd(v)][fnd(u)]++; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...