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 <iostream>
#include <vector>
#include <algorithm>
#include "game.h"
using namespace std;
int n, k;
bool valid[30005][30005];
vector<int> adj[30005];
void init(int N, int K) {
n = N;
k = K;
for (int i = 0; i < k; i++) {
for (int j = i + 1; j < k; j++) {
valid[i][j] = true;
}
}
}
bool dfs(int curr, int src) {
if (curr <= src) return true;
valid[src][curr] = true;
for (int i : adj[curr]) {
if (!valid[src][i] && dfs(i, src)) {
return true;
}
}
return false;
}
int add_teleporter(int u, int v) {
for (int i = 0; i < k; i++) {
if ((valid[i][u] || u == i) && dfs(v, i)) {
return 1;
}
}
adj[u].push_back(v);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |