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"
#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 (stderr)
monster.cpp:6:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
6 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |