# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982839 | vjudge1 | Permutation (APIO22_perm) | C++17 | 0 ms | 0 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 "perm.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k)
{
vector <int> resp;
long long pot = 0, prev = 1;
while (prev <= k)
{
pot = prev;
prev *= 2;
}
long long diff = k - pot;
for (long long i =(long long) (pot + diff) ; i > pot; i--)
{
resp.push_back(i);
}
for (int i = 0; i <= pot; i++)
{
resp.push_back(i);
}
return resp;
}
int main()
{
int k; cin>>k;
vector <int> r = construct_permutation((long long)k);
for(auto i: r)
{
cout<<i<<" ";
}
cout<<endl;
}