#include "monster.h"
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct Monster {
int index, wins;
bool operator<(const Monster &m) const {
return wins < m.wins;
}
};
std::vector<int> T;
std::vector<Monster> monsters;
/*int findPivot(int from, int to) {
int pivot = T[to - 1];
for (int i = from; i < to - 1; ++i) {
if (Query(i, pivot)) { // i wins
//swap(T[i], T[]);
}
}
}
void findSequence(int from, int to) {
if (from == to + 1) {
return;
}
int pivot = findPivot(from, to);
findSequence(from, pivot);
findSequence(pivot + 1, to);
}*/
std::vector<int> Solve(int N) {
T = std::vector<int>(N);
monsters = std::vector<Monster>(N);
// findSequence(0, N);
for (int i = 0; i < N; ++i) {
monsters[i] = {i, 0};
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < i; ++j) {
if (i == j) {
continue;
}
if (Query(i, j)) { // i wins
++monsters[i].wins;
} else {
++monsters[j].wins;
}
}
}
sort(monsters.begin(), monsters.end());
if (!Query(monsters[0].index, monsters[1].index)) {
swap(monsters[0], monsters[1]);
}
if (Query(monsters[N - 1].index, monsters[N - 2].index)) {
swap(monsters[N - 2], monsters[N - 1]);
}
for (int i = 0; i < N; ++i) {
T[monsters[i].index] = i;
}
return T;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
81 ms |
200 KB |
Output is correct |
17 |
Correct |
135 ms |
200 KB |
Output is correct |
18 |
Correct |
186 ms |
200 KB |
Output is correct |
19 |
Correct |
199 ms |
200 KB |
Output is correct |
20 |
Correct |
172 ms |
200 KB |
Output is correct |
21 |
Correct |
0 ms |
200 KB |
Output is correct |
22 |
Correct |
0 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
133 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
0 ms |
200 KB |
Output is correct |
30 |
Correct |
1 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
147 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
81 ms |
200 KB |
Output is correct |
17 |
Correct |
135 ms |
200 KB |
Output is correct |
18 |
Correct |
186 ms |
200 KB |
Output is correct |
19 |
Correct |
199 ms |
200 KB |
Output is correct |
20 |
Correct |
172 ms |
200 KB |
Output is correct |
21 |
Correct |
0 ms |
200 KB |
Output is correct |
22 |
Correct |
0 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
133 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
0 ms |
200 KB |
Output is correct |
30 |
Correct |
1 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
147 ms |
200 KB |
Output is correct |
33 |
Incorrect |
189 ms |
280 KB |
Wrong Answer [6] |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
206 ms |
284 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |