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>
#include "game.h"
const int MX = 1600 + 7 ;
using namespace std ;
int gn ;
bool del[MX][MX] ;
int viz[MX] ;
int Cnt = 0 ;
set<int> adz[MX] ;
int d[MX] ;
int rem[MX];
int manda ;
int all ;
void initialize(int x) {
gn = x;
manda = x - 1;
all = x * manda / 2 ;
for(int i = 0 ;i < x ; ++ i){
for(int j = 0 ;j < x ; ++ j){
if(i != j){
adz[i].insert(j) ;
}
}
rem[i] = x - 1;
}
}
void dfz(int x , int p){
if(viz[x]++)
return ;
for(auto u : adz[x]){
if(u == p)
continue ;
dfz(u , x) ;
}
}
int count(){
for(int i = 0 ; i < gn ; ++ i)
if(d[i] == gn - 1)
return 0 ;
return 1 ;
Cnt = 0 ;
memset(viz , 0 , sizeof viz) ;
for(int i = 0 ; i < gn; ++ i){
if(!viz[i]){
++ Cnt ;
}
dfz(i , i) ;
}
return Cnt ;
}
int hasEdge(int u, int v) {
adz[u].erase(v) ;
adz[v].erase(u) ;
d[u] ++ ;
d[v] ++ ;
rem[u] -- ;
rem[v] -- ;
all -- ;
if(count() == 1 && all + 1 != manda){
return 0 ;
}
d[u] -- ;
d[v] -- ;
adz[u].insert(v) ;
adz[v].insert(u) ;
manda -- ;
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... |