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 <iostream>
#include <stdio.h>
#include <fstream>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <set>
#include <deque>
#include <utility>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <limits.h>
using namespace std ;
const int N = 1502 ;
int degree[N] ;
set <int> pr[N] ;
int comp, father[N] ;
int fnd ( int x ) {
if ( father[x] == x ) return x ;
return father[x] = x ;
}
void uni ( int x, int y ) {
int fx = fnd ( x ), fy = fnd ( y ) ;
if ( fx==fy ) return ;
father[fx] = fy ;
comp-- ;
}
void initialize(int n) {
comp = n ;
for ( int i = 0 ; i < n ; ++i ) degree[i] = n-1, father[i] = i ;
for ( int i = 0 ; i < n ; ++i ) {
for ( int j = 0 ; j < n ; ++j )
if ( j!=i ) pr[i].insert ( j );
}
}
int hasEdge(int u, int v) {
int ans = 0 ;
if ( comp == 2 ) return 0 ;
if ( min(degree[u], degree[v]) <= 1 ) ans = 1, uni(u,v);
degree[u]-- ; degree[v]-- ;
pr[u].erase ( v ) ;
pr[v].erase ( u ) ;
if ( degree[u] == 1 ) degree[*pr[u].begin()]-- ;
if ( degree[v] == 1 ) degree[*pr[v].begin()]-- ;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |