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 mxn = 1505;
int n;
bool adj[mxn][mxn];
void initialize(int N) {
n = N;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) adj[i][j] = i != j;
}
bool visited[mxn];
// check if it can be connected
void dfs_could(int u) {
visited[u] = true;
for(int v = 0; v < n; v++) if(!visited[v] && adj[u][v]) {
dfs_could(v);
}
}
int hasEdge(int u, int v) {
bool add = false;
adj[u][v] = adj[v][u] = false;
fill(visited, visited+n, false);
dfs_could(0);
if(count(visited, visited+n, true) != n) {
adj[u][v] = adj[v][u] = true;
add = true;
}
return add;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |