#include "monster.h"
#include<bits/stdc++.h>
using namespace std;
namespace {
bool example_variable;
mt19937 rng(10184104810471);
int rnd(int l, int r) {
return l + rng() % (r - l + 1);
}
vector<int> sorting (vector<int> cur) {
if (cur.size() <= 1) return cur;
vector<int> left, right;
int x = cur[rnd(0, cur.size() - 1)];
for(int &j : cur) if (j != x) {
if (Query(x, j)) left.push_back(j);
else right.push_back(j);
}
left = sorting(left);
right = sorting(right);
if (!left.empty() && !right.empty()) {
if (Query(left.back(), right[0])) swap(left.back(), right[0]);
}
vector<int> ret;
for(int &j : left) ret.push_back(j);
ret.push_back(x);
for(int &j : right) ret.push_back(j);
return ret;
}
vector<int> solve(int n) {
vector<int> init;
for(int i = 0; i < n; i++) init.push_back(i);
vector<int> arr = sorting(init);
vector<int> ans(n);
for(int i = 0; i < n; i++) ans[arr[i]] = i;
return ans;
}
} // namespace
vector<int> Solve(int n) {
return ::solve(n);
}
Compilation message
monster.cpp:6:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
6 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
716 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |