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;
std::vector<int> construct_permutation(long long k)
{
deque<int> dq;
stack<bool> op;
while(k > 1){
if(k % 2 == 0){
op.push(0);
k /= 2;
}
else{
op.push(1);
k--;
}
}
int cur = 0;
while(!op.empty()){
int val = op.top();
op.pop();
if(val == 0) dq.push_back(cur++);
else dq.push_front(cur++);
}
vector<int> ret;
while(!dq.empty()){
ret.push_back(dq.front());
dq.pop_front();
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |