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 db long double
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define TII pair <treap*,treap*>
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#include "game.h"
using namespace std;
int n,i,u,v,r[100005],Left[1501][1501];
int root(int u) { return (u==r[u]) ? u : r[u]=root(r[u]); }
void initialize(int _n)
{
n=_n;
for(u=1;u<=n;u++) r[u]=u;
for(u=1;u<=n;u++)
for(v=1;v<=n;v++)
if(u!=v) Left[u][v]=1;
}
int hasEdge(int u,int v)
{
u++; v++;
u=root(u); v=root(v);
if(u==v) return 1;
Left[u][v]--; Left[v][u]--;
if(Left[u][v]==0)
{
r[u]=v;
for(int x=1;x<=n;x++)
if(r[x]==x)
{
Left[v][x]+=Left[u][x];
Left[x][v]+=Left[u][x];
}
return 1;
}
else return 0;
}
/*
int main()
{
freopen("game.inp","r",stdin);
freopen("game.out","w",stdout);
cin>>n;
initialize(n);
while(cin>>u>>v) cout<<hasEdge(u,v)<<'\n';
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |