Submission #892751

#TimeUsernameProblemLanguageResultExecution timeMemory
892751raul2008487Game (IOI14_game)C++17
0 / 100
1 ms344 KiB
#include<bits/stdc++.h> #define ll long long #define vl vector<ll> #include "game.h" using namespace std; const int sz = 1505; struct DSU{ vl e, ne; void init(ll n){ e.assign(n+1, -1); ne.assign(n+1, 0); } ll base(ll x){ if(e[x] < 0){ return x; } return e[x] = base(e[x]); } bool unite(ll x, ll y){ x = base(x); y = base(y); /*if(x == y){ ll fe = (e[x] * (e[x] + 1) / 2); ne[x]++; if(ne[x] == fe){ as = 1; } return as; } if(e[x] == -1 && e[y] == -1){as = 1;}*/ if(e[x] > e[y]){ swap(x, y); } if(x != y){e[x] += e[y];e[y] = x;} ll fe = (e[x] * (e[x] + 1) / 2); ne[x]++; if(x != y){ne[x] += ne[y], ne[y] = 0;} return ne[x] == fe; } }; DSU dsu; void initialize(int n) { dsu.init(n); } int hasEdge(int u, int v) { return dsu.unite(u, v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...