# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283235 | abyyskit | Game (IOI14_game) | C++14 | 675 ms | 19960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for(int i = x; i < y; ++i)
#define pb push_back
struct node{
bool vis = false;
vector<int> e;
int c;
int par;
int child;
};
vector<node> g;
int Find(int a){
if (g[a].par == a){
return g[a].par;
}
g[a].par = Find(g[a].par);
return g[a].par;
}
void Onion(int a, int b){
int ap = Find(a);
int bp = Find(b);
if (g[ap].child < g[bp].child){
swap(ap, bp);
}
g[ap].child += g[bp].child;
g[bp].par = ap;
FOR(i, 0, g.size()){
g[ap].e[i] += g[bp].e[i];
g[i].e[ap] = g[ap].e[i];
}
}
void initialize(int n) {
g.resize(n);
FOR(i, 0, n){
g[i].e.resize(n, 1);
g[i].c = n;
g[i].par = i;
g[i].child = 1;
}
}
int hasEdge(int u, int v) {
int up = Find(u);
int vp = Find(v);
if (up == vp){
return 0;
}
if (g[up].e[vp] != 1){
g[up].e[vp]--;
g[vp].e[up]--;
return 0;
}
else{
Onion(up, vp);
return 1;
}
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |