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"
const int N = 1.5e3 + 10;
int rq[N][N], p[N], n;
int gp(int x){
return p[x]==x ? x : p[x]=gp(p[x]);
}
void uni(int x, int y){
p[y] = x;
for(int i = 0; i < n; i++){
rq[i][x] += rq[i][y];
rq[i][y] = 0;
rq[x][i] += rq[y][i];
}
}
void initialize(int wtn) {
n = wtn;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
rq[i][j] = 1;
}
rq[i][i] = 0;
p[i] = i;
}
}
int hasEdge(int u, int v) {
u = gp(u);
v = gp(v);
rq[v][u]--;
rq[u][v]--;
if(!rq[u][v]){
uni(u, v);
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... |