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>
#define endl "\n"
using namespace std;
const int maxn = 1501;
int n;
int br[maxn][maxn];
int lead[maxn],sz[maxn];
void initialize(int N)
{
n = N;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(i!=j) br[i][j] = 1;
}
}
for(int i = 0; i < n; i++) lead[i] = i;
for(int i = 0; i < n; i++) sz[i] = 1;
}
int find_lead(int x)
{
if(lead[x]==x) return x;
return lead[x] = find_lead(x);
}
int hasEdge(int u, int v)
{
u = find_lead(u);
v = find_lead(v);
if(br[u][v]==1)
{
if(sz[u]>sz[v]) swap(u,v);
sz[v] += sz[u];
lead[u] = v;
for(int i = 0; i < n; i++)
{
if(i==v||i==u) continue;
br[v][i] += br[u][i];
br[i][v] += br[i][u];
br[u][i] = br[i][u] = 0;
}
return 1;
}
else
{
br[u][v]--;
br[v][u]--;
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |