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 N = 1500 + 5;
int n, cnt[N][N];
struct DSU{
int par[N], setcnt;
void init(int n){
for(int i = 0; i < n; i++) par[i] = i;
}
int setfind(int a){
if(a == par[a]) return a;
else return par[a] = setfind(par[a]);
}
void setunion(int a, int b){
par[b] = par[a];
for(int v = 0; v < n; v++) cnt[min(a, v)][max(a, v)] += cnt[min(b, v)][max(b, v)];
}
};
DSU dsu;
void initialize(int N){
n = N;
dsu.init(n);
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
cnt[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
u = dsu.setfind(u), v = dsu.setfind(v);
if(v < u) swap(v, u);
if(u == v) return 1;
else{
cnt[u][v]--;
if(cnt[u][v] == 0){
dsu.setunion(u, v);
return 1;
}
else 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... |