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 ll int
#define pll pair<ll,ll>
#define ff first
#define ss second
//#define endl "\n"
#define pb push_back
#define F(i,a,b) for(ll i=a;i<=b;i++)
const ll maxn=1e3+5e2+100;
const ll base=2e9;
const ll mod= 1e9+7 ;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll par[maxn];
ll val[maxn][maxn];
ll find_par(ll u)
{
if (u==par[u]) return u;
return par[u]=find_par(par[u]);
}
ll n;
void initialize(int n1)
{
n=n1;
for (int i=1;i<=n;i++)
{
par[i]=i;
for (int j=1;j<=n;j++)
{
if (i!=j) val[i][j]=1;
}
}
}
int hasEdge(int u, int v)
{
u=find_par(u);
v=find_par(v);
if (u==v)
{
return 0;
}
else
{
if (val[u][v]==1)
{
for (int t=1;t<=n;t++)
{
if (t==find_par(t))
{
ll h=val[u][t]+val[v][t];
val[u][t]=h;
val[t][u]=h;
}
}
par[v]=u;
return 1;
}
else
{
val[u][v]--;
val[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... |