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>
using namespace std;
const int MAXN = 1510;
int N;
int rep[MAXN], tam[MAXN];
int conect[MAXN][MAXN];
int find(int a){
if(rep[a] == a) return a;
return rep[a] = find(rep[a]);
}
void uni(int a, int b){
if(tam[a] < tam[b]) swap(a, b);
rep[b] = a;
tam[a] += tam[b];
for(int i = 0; i < N; i++){
conect[a][i] += conect[b][i];
conect[i][a] += conect[i][b];
}
}
void initialize(int n) {
N = n;
for(int i = 0; i < N; i++){
rep[i] = i;
tam[i] = 1;
for(int j = 0; j < N; j++)
conect[i][j] = 1;
}
}
int hasEdge(int u, int v) {
u = find(u), v = find(v);
conect[u][v]--;
conect[v][u]--;
if(conect[u][v] != 0) return 0;
uni(u, v);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |