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 "perm.h"
#include "bits/stdc++.h"
using namespace std;
vector<int> construct_permutation(long long k) {
vector<int> ans;
int mx = 1000, mn = -1000;
vector<int> steps;
while (k != 1) {
if (k%2) ans.push_back(mn++);
ans.push_back(mx--);
k /= 2;
} reverse(ans.begin(), ans.end());
map<int, int> fr;
vector<int> tmp = ans;
int ind = 0;
sort(tmp.begin(), tmp.end());
for (int i:tmp) {
fr[i] = ind++;
}
for (int&i:ans) i = fr[i];
return ans;
}
/*
1 2 4 5 10 11 22 23
{}
{0 1 -1 2 -2 3 -3}
{3 4 2 5 1 6 0}
{}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |