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"
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define F first
#define S second
using namespace std;
const int tam=1505;
int P[tam];
int M[tam][tam];
int sz[tam];
int N;
int _find(int x){
if(P[x]==x)return x;
return P[x]=_find(P[x]);
}
void _union(int x, int y){
if(sz[x]<sz[y])swap(x,y);//quiero añadir todo a x
P[y]=x;
sz[x]+=y;
vector<bool>vis(N+1,false);
for(int i=0;i<N;i++){
int j=_find(i);
if(vis[j])continue;
vis[j]=1;
M[x][j]+=M[y][j];
M[j][x]+=M[y][j];
}
}
void initialize(int n) {
N=n;
for(int i=0;i<=n;i++){
P[i]=i;
}
for(int i=0;i<n;i++){
sz[i]=1;
for(int l=0;l<n;l++){
M[i][l]=1;
}
}
}
int hasEdge(int u, int v) {
u=_find(u);
v=_find(v);
if(v==u)return 0;
if(M[u][v]>1){
M[u][v]--;
M[v][u]--;
return 0;
}
_union(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... |