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"
namespace Solver {
const int MAXN = 80;
int adj[MAXN][MAXN];
int n;
void init( int N ) {
n = N;
for( int i = 0 ; i < n ; i++ ){
for( int j = 0 ; j < n ; j++ )
adj[i][j] = 1;
adj[i][i] = 0;
}
}
void remove_edge( int u, int v ) { adj[u][v] = adj[v][u] = 0; }
void insert_edge( int u, int v ) { adj[u][v] = adj[v][u] = 1; }
bool viz[MAXN];
void dfs( int u ) {
viz[u] = true;
for( int v = 0 ; v < n ; v++ )
if( !viz[v] && adj[u][v] )
dfs( v );
}
bool connected( int u, int v ) {
for( int i = 0 ; i < n ; i++ )
viz[i] = false;
dfs( u );
return viz[v];
}
};
void initialize(int n) {
Solver::init( n );
}
int hasEdge(int u, int v) {
Solver::remove_edge( u, v );
bool ret = true;
if( Solver::connected( u, v ) )
ret = false;
else
Solver::insert_edge( u, v );
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |