#include "game.h"
#include <algorithm>
#include <vector>
using namespace std;
namespace solution_ns {
int n;
vector<vector<int>> G;
void dfs(int u, vector<int> &was) {
if (was[u])
return;
was[u] = 1;
for (int v = 0; v < n; v++)
if (G[u][v])
dfs(v, was);
}
}; // namespace solution_ns
void initialize(int n) {
using namespace solution_ns;
solution_ns::n = n;
G.assign(n, vector<int>(n, 1));
for (int i = 0; i < n; i++)
G[i][i] = 0;
}
int hasEdge(int u, int v) {
using namespace solution_ns;
G[u][v] = G[v][u] = 0;
vector<int> was(n);
dfs(0, was);
if (*min_element(was.begin(), was.end()))
return 0;
G[u][v] = G[v][u] = 1;
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... |