# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
892753 | raul2008487 | Game (IOI14_game) | C++17 | 1 ms | 4540 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<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#include "game.h"
using namespace std;
const int sz = 1505;
ll a[sz][sz];
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);
bool as = 0;
if(x == y){assert(0);}
if(e[x] > e[y]){
swap(x, y);
}
a[x][y]++;
a[y][x]++;
ll nume = ne[x] + ne[y] + a[x][y];
ll cd = e[x] + e[y];
ll fe = (cd * (cd + 1) / 2);
if(nume == fe){
e[x] += e[y];
e[y] = x;
ne[x] = fe;
return true;
}
else{
return 0;
}
}
};
DSU dsu;
void initialize(int n) {
dsu.init(n);
ll i, j;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
a[i][j] = 0;
}
}
}
int hasEdge(int u, int v) {
if(dsu.unite(u, v)){
return 1;
}
return 0;
}
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... |