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"
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
const ll NMAX = 5001;
const ll VMAX = 1000001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 1000000;
const ll base = 13137;
const ll nr_of_bits = 16;
int p[NMAX];
vector <int> comp[NMAX];
int q[NMAX][NMAX];
int N;
void initialize(int n) {
N = n;
for(int i = 0; i < N; i++)
{
p[i] = i;
comp[i].push_back(i);
}
}
int root(int x){
if(x == p[x])
return x;
return p[x] = root(p[x]);
}
int hasEdge(int u, int v) {
q[u][v] = 1;
u = root(u);
v = root(v);
if(u == v){
return 0; /// we don't really care
}
int ok = 0;
for(auto x : comp[u]){
for(auto y : comp[v]){
ok += (!q[x][y]);
}
}
if(ok){
return 0;
}
for(auto x : comp[v])
comp[u].push_back(x);
p[u] = v;
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |