# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542907 | Vladth11 | Game (IOI14_game) | C++14 | 417 ms | 31596 KiB |
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) {
u = root(u);
v = root(v);
q[u][v]++;
q[v][u]++;
if(u == v){
return 0; /// we don't really care
}
int ok = (q[u][v]) == (comp[u].size() * comp[v].size());
if(!ok){
return 0;
}
for(int i = 0; i < N; i++){
q[v][i] += q[u][i];
}
for(int i = 0; i < N; i++){
q[i][v] += q[i][u];
}
for(auto x : comp[u])
comp[v].push_back(x);
p[u] = v;
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |