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);
p[b] = a;
for(int i = 0; i< n; i++)
{
if(findset(i) != i) continue;
bw[a][i] += bw[b][i];
bw[i][a] += bw[i][b];
}
}
int hasEdge(int u, int v)
{
int x = findset(u), y = findset(v);
int res = 0;
if(bw[x][y] == 1) res = 1;
if(res)
{
unionset(x, y);
}
else
{
bw[x][y]--; bw[y][x]--;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |