Submission #1016792

#TimeUsernameProblemLanguageResultExecution timeMemory
1016792serkanrashidGame (IOI14_game)C++14
0 / 100
129 ms262144 KiB
#include "game.h" #include <bits/stdc++.h> #define endl "\n" using namespace std; const int maxn = 1500; int n; int br[maxn][maxn]; int lead[maxn],sz[maxn]; void initialize(int N) { n = N; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(i!=j) br[i][j] = 1; } } for(int i = 0; i < n; i++) lead[i] = i; for(int i = 0; i < n; i++) sz[i] = 1; } int find_lead(int x) { if(lead[x]==x) return x; return lead[x] = find_lead(x); } int hasEdge(int u, int v) { u = find_lead(u); v = find_lead(v); if(br[u][v]==1) { if(sz[u]>sz[v]) swap(u,v); sz[v] += sz[u]; lead[u] = v; for(int i = 0; i < n; i++) { if(i==v||i==u) continue; br[v][i] += br[u][i]; br[i][v] += br[i][u]; br[u][i] = br[i][u] = 0; } return 1; } else { br[u][v]--; br[v][u]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...