Submission #130815

#TimeUsernameProblemLanguageResultExecution timeMemory
130815MAMBAGame (IOI14_game)C++17
100 / 100
493 ms25464 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1510; int mat[N][N]; int par[N], n_, sz[N]; int getPar(int v) { return par[v] == v ? v : par[v] = getPar(par[v]); } void initialize(int n) { n_ = n; iota(par, par + n , 0); memset(mat , 0 , sizeof(mat)); fill(sz , sz + n , 1); } int hasEdge(int u, int v) { u = getPar(u); v = getPar(v); mat[u][v]++; mat[v][u]++; if (mat[u][v] == sz[u] * sz[v]) { par[u] = v; sz[v] += sz[u]; for (int i = 0 ; i < n_; i++) if (par[i] == i) { mat[i][v] += mat[i][u]; mat[v][i] += mat[i][u]; } return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...