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 ;
const int N = 1505 ;
const int inf = 1e9 ;
int n ;
set <int> g[N] ;
bool vis[N] ;
void initialize(int m) {
n = m ;
for ( int i = 1 ; i <= n ; i ++ ){
for ( int j = i + 1 ; j <= n ; j ++ ){
g[i].insert(j) ;
g[j].insert(i) ;
}
}
}
void dfs ( int v , int a , int b ){
vis[v] = 1 ;
for ( auto to : g[v] ){
if ( (v == a && to == b) || (v == b && to == a) || vis[to] ) continue ;
dfs(to,a,b) ;
}
}
int hasEdge(int u, int v) {
if ( u > v ) swap ( u , v ) ;
for ( int i = 1 ; i <= n ; i ++ ) vis[i] = 0 ;
dfs(u,u,v) ;
if ( vis[v] ){
g[u].erase(v) ;
g[v].erase(u) ;
return 0 ;
}
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... |