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;
int n;
vector<int> rem;
vector<int> with;
vector<vector<int>> answered;
void initialize(int n_) {
n = n_;
rem.resize(n);
with.resize(n);
answered.resize(n);
for (int i = 0; i < n; ++i) {
answered[i].resize(n);
}
with[0] = true;
for (int i = 1; i < n; ++i) {
rem[i] = 1;
}
}
int hasEdge(int u, int v) {
answered[u][v] = answered[v][u] = 1;
if (!with[u] && !with[v]) {
return 0;
}
if (with[u] && with[v]) {
return 1;
}
if (!with[u]) {
swap(u, v);
}
// u is the one with 0
if (rem[v] - 1 > 0) {
--rem[v];
return 0;
} else {
with[v] = true;
for (int i = 0; i < n; ++i) {
if (!answered[v][i] && !with[i]) {
++rem[i];
}
}
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... |