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>
using namespace std;
#define ll long long
#define pb push_back
const int INF=100000000;
int father[2000];
int cnt[2000][2000];
int tamano[2000];
int N;
void findF(int x, int y){
for(int i=0;i<N;i++){
if(father[i]==x){
father[i]=y;
}
}
}
void initialize(int n) {
memset(cnt,0,sizeof(cnt));
for(int i=0;i<n;i++){
father[i]=i;
tamano[i]=1;
}
N=n;
}
int hasEdge(int u, int v) {
u=father[u];
v=father[v];
cnt[u][v]++;
cnt[v][u]++;
//cout<<father[u]<<" "<<father[v]<<" FATHER"<<endl;
//cout<<tamano[u]<<" "<<tamano[v]<<" TAMANO"<<endl;
//cout<<cnt[u][v]<<" CNT"<<endl;
if(tamano[u]*tamano[v]==cnt[u][v] || tamano[u]*tamano[v]==cnt[v][u]){
if(tamano[v]>tamano[u]) swap(u,v);
findF(v,u);
tamano[u]+=tamano[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... |