This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//by szh
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const int maxn = 1555;
int n;
int f[maxn];
int sz[maxn];
int cnt[maxn][maxn];
set <int> s;
void initialize(int N) {
n = N;
rep(i,0,n) f[i]=i,sz[i]=1,s.insert(i);
memset(cnt,0,sizeof(cnt));
return;
}
int getf(int u) {
if (f[u]==u) return u;
else return f[u] = getf(f[u]);
}
int hasEdge(int u,int v) {
int fu = getf(u),fv = getf(v);
if (fu==fv) return 0;
if (sz[fu]*sz[fv]-1==cnt[fu][fv]) {
f[fu] = fv;
sz[fv] += sz[fu];
s.erase(fu);
for (auto it:s) {
if (it==fv) continue;
cnt[fv][it] += cnt[fu][it];
cnt[it][fv] += cnt[fu][it];
assert(cnt[it][fv]==cnt[fv][it]);
}
return 1;
}
else {
cnt[fu][fv]++;
cnt[fv][fu]++;
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... |