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;
const int maxn = 1500 + 10;
int n;
int par[maxn];
int adj[maxn][maxn];
int get_par(int v){
return par[v] < 0 ? v : par[v] = get_par(par[v]);
}
void initialize(int N){
n = N;
memset(par, -1, sizeof par);
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (i != j)
adj[i][j] = 1;
}
int hasEdge(int u, int v){
v = get_par(v), u = get_par(u);
if (adj[v][u] > 1){
adj[v][u] --, adj[u][v] --;
return false;
}
adj[v][u] --, adj[u][v] --;
for (int i = 0; i < n; i++)
if (get_par(i) == i and i != v and i != u)
adj[v][i] += adj[u][i], adj[i][v] += adj[i][u];
par[u] = v;
return true;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |