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;
for (int i = 0; i < vcnt; ++ i)
{
if(p[i] == u)continue;
if(p[i] == v)continue;
cnt[p[i]][u] += cnt[p[i]][v];
cnt[u][p[i]] += cnt[v][p[i]];
}
p[v] = u;
for (int i = 0; i < vcnt; ++ i)
{
cnt[i][v] = 0;
cnt[v][i] = 0;
}
return 1;
}
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... |