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;
int A[1500][1500],sz[1500],P[1500];
int par (int a) {
return a == P[a] ? a : P[a] = par (P[a]);
}
int join(int a,int b) {
int x = par(a);
int y = par(b);
if (x == y) return 0;
if (A[x][y] != 1) { A[x][y]--;A[y][x]--;return 0;}
if (sz[x] < sz[y]) swap(x,y);
for (int i = 0; i < 1500; i++)
if (i != x && i != y) {
int t = A[x][i] + A[y][i];
A[x][i] = A[i][x] = t;
}
P[y] = x;
sz[x] += sz[y];
return 1;
}
void initialize(int n) {
for (int i = 0; i < n; i++) {
sz[i] = 1;
P[i] = i;
for (int j = 0;j < n; j++) {
if (i != j) A[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
return join(u,v);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |