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 <cstdint>
#include <vector>
#include "game.h"
#include <iostream>
using i64 = int64_t;
const i64 MAXN = 1500;
i64 N;
bool adj[MAXN][MAXN];
void initialize(int n) {
N = n;
for (i64 i = 0; i < N; i++) {
for (i64 j = 0; j < N; j++) {
if (i != j) adj[i][j] = true;
}
}
}
bool connected(int u, int v) {
std::vector<int> stack;
std::vector<bool> visited(N, false);
stack.push_back(u);
while (!stack.empty()) {
int i = stack.back();
stack.pop_back();
if (visited[i]) {
continue;
}
visited[i] = true;
if (i == v) return true;
for (int j = 0; j < N; j++) {
if (adj[i][j] && !visited[j]) {
stack.push_back(j);
}
}
}
return false;
}
int hasEdge(int u, int v) {
u -= 1;
v -= 1;
adj[u][v] = false;
adj[v][u] = false;
if (connected(u, v)) {
return false;
} else {
adj[u][v] = true;
adj[v][u] = true;
return true;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |