///~~~LOTA~~~///
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 60
ll pwr[N];
vector<int> construct_permutation(ll n){
pwr[0]=1;
for(ll i=1;i<N;i++)
pwr[i]=pwr[i-1]*2LL;
ll m=log2(n);
vector<int> u,v;
for(int i=0;i<m;i++)
v.append(i);
n-=pwr[m];
for(int i=m-1;i>0;i--){
if(n<pwr[i]) continue;
n-=pwr[i];
u.append(v[m-i]);
for(int j=m-i;j<m;j++)
v[j]++;
}
if(n) u.append(v.back()+1);
reverse(all(u));
for(auto& i:v)
u.append(i);
return u;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
480 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |