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;
using idata = vector<int>;
using bdata = vector<bool>;
using bgrid = vector<bdata>;
bgrid roads;
idata visited; int stage = 1;
int N;
void initialize(int _N) {
N = _N;
visited.resize(N, 0);
roads .resize(N, bdata(N, true));
}
bool dfs (int s, int t) {
if (s == t) return true;
if (visited[s] == stage) return false;
visited[s] = stage;
for (int i = 0; i < N; i ++) if (i != s && roads[s][i])
if (dfs(i, t))
return true;
return false;
}
int hasEdge(int u, int v) {
stage ++;
roads[u][v] = false;
roads[v][u] = false;
if (dfs(u, v)) return 0;
roads[u][v] = true;
roads[v][u] = true;
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... |