Submission #640198

#TimeUsernameProblemLanguageResultExecution timeMemory
640198ymmGame (IOI14_game)C++17
100 / 100
380 ms25256 KiB
#include "game.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; static const int N = 1510; static int par[N], sz[N], ask[N][N]; static int root(int v) { return par[v] == -1? v: (par[v] = root(par[v])); } void initialize(int n) { fill(par, par+N, -1); fill(sz, sz+N, 1); } int hasEdge(int u, int v) { v = root(v); u = root(u); ask[v][u]++; ask[u][v]++; if (ask[v][u] == sz[v] * sz[u]) { par[u] = v; sz[v] += sz[u]; Loop (i,0,N) { ask[v][i] += ask[u][i]; ask[i][v] += ask[i][u]; } return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...