# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117572 | 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 int long long
#define endl '\n'
#define pb push_back
//const int MOD=819276405795233,MAXN=1e6+5,inf=1e9+5;
bool flag=1;
vector<int> construct_permutation(long long k)
{
deque<int> dq;
int cnt=-1,x=1,r=1;
if(flag)r=0;
flag=0;
while (x-r <= k) {
x *= 2;
cnt++;
}
x-=r;
x /= 2;
// cout<<k<<' '<<cnt<<' '<<x<<endl;
for (int i = cnt-1; i >= 0; i--)dq.push_front(i);
k -= x;
vector<int> v;
if(k>0)v=construct_permutation(k);
for(int i=0;i<v.size();i++)v[i]+=dq.size();
for(int i=0;i<dq.size();i++)v.pb(dq[i]);
return v;
}
/*signed main()
{
vector<int> v=construct_permutation(14);
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... |