Submission #67002

#TimeUsernameProblemLanguageResultExecution timeMemory
67002CrownGame (IOI14_game)C++14
0 / 100
3 ms644 KiB
#include "game.h" #include <bits/stdc++.h> const int maxn = 1505; int p[maxn]; int bw[maxn][maxn]; int n; void initialize(int _n) { n = _n; for(int i = 0; i< n; i++) p[i] = i; for(int i = 0; i< n; i++) { for(int j = i+1; j< n; j++) { bw[i][j] = bw[j][i] = 1; } } } int findset(int x) { if(p[x] == x) return x; return p[x] = findset(p[x]); } void unionset(int x, int y) { int a = findset(x), b = findset(y); for(int i = 0; i< n; i++) { if(findset(i) != i) continue; bw[a][i] += bw[b][i]; bw[i][a] += bw[i][b]; } } int hasEdge(int u, int v) { int x = findset(u), y = findset(v); int res = 0; if(bw[x][y] == 1) res = 1; if(res) { unionset(x, y); } else { bw[x][y]--; bw[y][x]--; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...