# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117631 | erering | Permutation (APIO22_perm) | C++17 | 1 ms | 336 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>
#include "perm.h"
using namespace std;
#define endl '\n'
#define pb push_back
bool flag=1;
vector<int> construct_permutation(long long k)
{
long long cnt=-1,x=1,r=1;
if(flag)r=0;
flag=0;
while (x-r <= k) {
x *= 2;
cnt++;
}
x-=r;
x /= 2;
vector<int> vec;
for (int i = 0; i < cnt; i++)vec.pb(i);
k -= x;
vector<int> v;
if(k>0)v=construct_permutation(k);
for(int i=0;i<v.size();i++)v[i]+=vec.size();
for(int i=0;i<vec.size();i++)v.pb(vec[i]);
return v;
}
/*signed main()
{
vector<int> v=construct_permutation(12);
cout<<endl;
for(auto i:v)cout<<i<<' ';
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |