# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061166 | sleepntsheep | Monster Game (JOI21_monster) | C++17 | 1 ms | 740 KiB |
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 "monster.h"
using namespace std;
namespace {
}
vector<int> Solve(int N) {
static int a[201][201], w[201], l[201];
for (int i = 0; i < N; ++i) w[i] = 0, l[i] = 0;
for (int i = 0; i < N; ++i) for (int j = i + 1; j < N; ++j) {
a[i][j] = Query(i, j);
if (a[i][j]) ++w[i];
else ++w[j];
a[j][i] = !a[i][j];
}
int x1 { -1 }, x2;
for (int i = 0; i < N; ++i) {
if (w[i] == 1) {
if (~x1) x2 = i;
else x1 = i;
}
}
vector<int> T(N), taken(N), Q(N);
if (a[x1][x2]) T[0] = x1, T[1] = x2;
else T[0] = x2, T[1] = x1;
taken[x1] = taken[x2] = 1;
for (int j = 2; j < N; ++j) {
for (int i = 0; i < N; ++i) if (not taken[i]) {
if (a[T[j - 1]][i]) {
T[j] = i;
break;
}
}
}
for (int i = 0; i < N; ++i) Q[T[i]] = i;
return Q;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |