#include "monster.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> Solve(int N) {
n = N;
vector<int> a(n, -1);
vector<int> loss(n, 0), win(n, 0);
int idxa = -1, idxb = -1;
int i2 = -1, j2 = -1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
int ans = Query(i, j);
if (ans == true) {
win[i]++;
loss[j]++;
}
else {
loss[i]++;
win[j]++;
}
}
a[i] = abs(loss[i] - n) - 1;
if (a[i] == 1) {
if (idxa == -1) idxa = i;
else idxb = i;
}
if (a[i] == n-2) {
if (i2 == -1) i2 = i;
else j2 = i;
}
}
int ans = Query(idxa, idxb);
if (ans) {
a[idxa] = 0;
}
else a[idxb] = 0;
ans = Query(i2, j2);
if (ans) {
a[j2] = n-1;
}
else a[i2] = n-1;
for (int i = 0; i < n; i++) cout << a[i] << " ";
cout << "\n";
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |