# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66999 | Crown | Game (IOI14_game) | C++14 | 3 ms | 588 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>
const int maxn = 1505;
int p[maxn];
int bw[maxn][maxn];
int n;
void initialize(int _n)
{
n = _n;
for(int i = 0; i< n; i++) p[i] = i;
for(int i = 0; i< n; i++)
{
for(int j = i+1; j< n; j++)
{
bw[i][j] = bw[j][i] = 1;
}
}
}
int findset(int x)
{
if(p[x] == x) return x;
return p[x] = findset(p[x]);
}
void unionset(int x, int y)
{
int a = findset(x), b = findset(y);
for(int i = 0; i< n; i++)
{
bw[x][i] += bw[y][i];
bw[i][x] += bw[i][y];
}
}
int hasEdge(int u, int v)
{
int x = findset(u), y = findset(v);
int res = 0;
assert(x != y);
if(x != y && bw[x][y] == 1) res = 1;
bw[x][y]--; bw[y][x]--;
if(res)
{
unionset(x, y);
}
return res;
}
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... |