This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
int n;
vector<int> ans;
int publish(vector<int> r);
void answer(vector<int> r);
bool comp(int a, int b){
int ans1, ans2;
vector<int> perm = {a, b};
for (int i = 1; i <= n; i++) if (i != a && i != b) perm.push_back(i);
ans1 = publish(perm);
swap(perm[0], perm[1]);
ans2 = publish(perm);
return ans1 < ans2;
}
void solverange(int l, int r){
if (r - l < 2) return;
int mid = (l + r) / 2;
solverange(l, mid);
solverange(mid, r);
queue<int> a, b;
for (int i = l; i < mid; i++) a.push(ans[i]);
for (int i = mid; i < r; i++) b.push(ans[i]);
for (int i = l; i < r; i++){
if (a.empty()){
ans[i] = a.front();
a.pop();
} else if (b.empty()){
ans[i] = b.front();
b.pop();
} else if (comp(a.front(), b.front())){
ans[i] = a.front();
a.pop();
} else {
ans[i] = b.front();
b.pop();
}
}
}
void solve(int N){
n = N;
for (int i = 1; i <= n; i++) ans.push_back(i);
sort(ans.begin(), ans.end());
solverange(0, n);
answer(ans);
}
Compilation message (stderr)
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(v.size() != N) {
| ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(v.size() != N) {
| ~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |