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;
#define graph vector<vector<bool>>
graph n_roads;
bool has_road (int a, int b) {
return !n_roads[a][b];
}
vector<int> visited;
int stage = 0;
int nbNodes;
bool find (int pos, int target) {
if (pos == target) return true;
if (visited[pos] == stage) return false;
visited[pos] = stage;
for (int n = 0; n < nbNodes; n ++)
if (has_road(pos, n) && find(n, target))
return true;
return false;
}
void initialize(int n) {
nbNodes = n;
n_roads.resize(n, vector<bool>(n, false));
visited.resize(n, -1);
}
int hasEdge(int u, int v) {
n_roads[u][v] = true;
n_roads[v][u] = true;
stage ++;
if (find(u, v))
return 0;
n_roads[u][v] = false;
n_roads[v][u] = false;
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... |