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;
int par[1500],sz[1500],say[1500][1500];
int find(int node){
if (par[node]==node) return node;
return par[node]=find(par[node]);
}
int n;
void initialize(int n) {
::n=n;
iota(par,par+n,0);
fill(sz,sz+n,1);
memset(say,0,sizeof(say));
}
int hasEdge(int u, int v) {
if (find(u)==find(v)) return 0;
u=find(u);
v=find(v);
if (say[u][v]!=sz[u]*sz[v]-1 && say[v][u]!=sz[u]*sz[v]-1){
say[u][v]++,say[v][u]++;
return 0;
}
//mergelemeye karar verdiysem
if (sz[u]<sz[v]) swap(u,v);
for (int i = 0; i < n; i++){
say[u][find(i)]+=say[v][i];
}
sz[u]+=sz[v];
sz[v]=0;
par[v]=u;
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... |