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 ii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
int n , cnt[1505] , used[1505] , par[1505] , adj[1505][1505] ;
int find_root(int x){
if(par[x] == x) return x ;
return par[x] = find_root(par[x]) ;
}
void initialize(int N) {
n = N ;
for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(i != j) adj[i][j] = 1;
for(int i=0;i<n;i++) par[i] = i ;
}
int hasEdge(int u, int v) {
int pu = find_root(u), pv = find_root(v) ;
if(pu == pv) return 0 ;
adj[pu][pv]-- ; adj[pv][pu]--;
if(adj[pv][pu] == 0) {
par[pv] = pu ;
int rt ;
for(int i=0;i<n;i++){
rt = find_root(i) ;
if(rt != i || rt == pu) continue ;
adj[pu][i] = adj[pu][i] + adj[pv][i] ;
adj[i][pu] = adj[pu][i] ;
}
return 1;
}
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... |