#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
using lli=long long;
#define deb(x) cout<<#x<<": "<<x<<endl;
vector<int> construct_permutation(long long k)
{
int cont=0;
lli pow2=2;
while(pow2*2<= k){
pow2*=2;
cont++;
}
k-=pow2;
vector<int> ans;
int cont2=cont+1;
while(cont>=0){
if(pow2<k){
ans.pb(cont2);
cont2++;
k-=pow2;
}
ans.pb(cont);
cont--;
pow2/=2;
}
if(k==1){
ans.pb(cont2);
}
reverse(ans.begin(), ans.end());
// deb(k);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |