# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083818 | alexander707070 | Permutation (APIO22_perm) | C++17 | 2 ms | 496 KiB |
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<bits/stdc++.h>
#define MAXN 200007
using namespace std;
int num;
deque<int> perm;
vector<int> ans,w;
bool fr;
void mult(){
perm.push_back(num);
num++;
}
void add(){
perm.push_front(num);
num++;
}
void reset(){
fr=false;
num=0;
perm.clear(); ans.clear();
}
vector<int> construct_permutation(long long k){
reset();
for(int i=62;i>=0;i--){
if((1LL<<i)>k)continue;
if(((1LL<<i)&k)>0 and fr){
add();
}else if(((1LL<<i)&k)>0)fr=true;
if(i>0)mult();
}
for(int i=0;i<perm.size();i++){
ans.push_back(perm[i]);
}
return ans;
}
/*int main(){
w=construct_permutation(5);
for(int i:w)cout<<i<<" ";
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |