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 long long
#define pii pair<ll, ll>
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i<b; ++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int iinf = 0x3f3f3f3f;
const int maxn = 1505;
int par[maxn], sz[maxn];
int ed[maxn][maxn]; // number of edges between the groups, maintain both directions
int n;
void initialize(int _n) {
n = _n;
REP(i,n) {
par[i] = i; sz[i] = 1;
}
REP(i,n) REP(j,n) ed[i][j] = 0;
}
int find(int x) {return x == par[x]? x : par[x] = find(par[x]);}
int hasEdge(int u, int v) {
u = find(u); v = find(v);
assert(u!=v);
if (ed[u][v] == sz[u] * sz[v]-1) {
// merge
par[u] = v;
REP(j,n) {
if (j!=u && j!=v) {
ed[v][j] += ed[u][j];
ed[j][v] = ed[v][j];
}
}
sz[v] += sz[u];
return 1;
}else{
++ed[u][v]; ++ed[v][u];
return 0;
}
}
// #ifdef BALBIT
// signed main(){
// }
// #endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |