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;
const int MAXN = 2e3 + 10;
int vcnt;
int p[MAXN];
int cnt[MAXN][MAXN];
vector < int > g[MAXN];
void initialize(int n)
{
vcnt = n;
for (int i = 0; i < n; ++ i)
p[i] = i;
for (int i = 0; i < n; ++ i)
{
for (int j = 0; j < n; ++ j)
if(i != j)cnt[i][j] = 1;
}
}
int find_leader(int i)
{
if(i == p[i])return i;
return (p[i] = find_leader(p[i]));
}
int hasEdge(int u, int v)
{
u = find_leader(u);
v = find_leader(v);
if(u == v)
{
return 0;
}
if(cnt[u][v] == 1)
{
//cout << 1 << endl;
cnt[u][v] = 0;
cnt[v][u] = 0;
for (int i = 0; i < vcnt; ++ i)
{
if(i == u)continue;
if(i == v)continue;
cnt[i][u] += cnt[i][v];
cnt[u][i] += cnt[v][i];
}
p[v] = u;
for (int i = 0; i < vcnt; ++ i)
{
cnt[i][v] = 0;
cnt[v][i] = 0;
}
cnt[u][v] = 0;
return 1;
}
cnt[u][v] --;
cnt[v][u] --;
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... |