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>
#include "game.h"
using namespace std;
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
int N;
int par[1505];
int stuf[1505][1505], sz[1505];
int getr(int x){
return (par[x] == x ? x : par[x] = getr(par[x]));
}
void merge(int a, int b){
a = getr(a), b = getr(b);
if(a == b)return;
par[b] = a;
sz[a] += sz[b];
for(int i=0;i<N;i++)stuf[a][i] += stuf[b][i], stuf[i][a] += stuf[i][b];
}
void initialize(int n){
N = n;
for(int i=0;i<n;i++)par[i] = i, sz[i] = 1;
}
int cnt = 0;
int hasEdge(int u, int v){
int pu = getr(u), pv = getr(v);
assert(pu != pv);
stuf[pu][pv]++;
stuf[pv][pu]++;
//cerr << pu << " " << pv << " " << sz[pu] << " " << sz[pv] << " " << stuf[pu][pv] << '\n';
if(stuf[pu][pv] == sz[pu] * sz[pv]){
merge(pu, pv);
return 1;
}
else 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... |