This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=2e3+50;
const int mod=1e9+7;
using namespace std;
int i,n,p[nmax],sz[nmax],s[nmax];
int fnd(int x)
{
if(p[x]==x)return x;
return p[x]=fnd(p[x]);
}
void uni(int x,int y)
{
if(x!=y)
{
if(sz[x]<sz[y])swap(x,y);
p[y]=x;
sz[x]+=sz[y];
s[x]+=s[y]-2;
}
else s[x]-=2;
}
void initialize(int n)
{
for(int i=1;i<=n;i++)
{
p[i]=i;
sz[i]=1;
s[i]=n-1;
}
}
int hasEdge(int u, int v)
{
u++,v++;
int x=fnd(u),y=fnd(v);
if(x==y || min(s[x],s[y])==1)
{
uni(x,y);
return 1;
}
s[x]--,s[y]--;
return 0;
}
/*int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
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... |