#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
using ll = long long;
std::vector<int> construct_permutation(long long k) {
bitset<64> bs(k);
vector<int> ans;
int n = (int)log2(k);
//int maxx=n-1;
int cur=n-1;
for(int i=0;i<n;i++){
ans.push_back(i);
}
n--;
while(n>=0){
if(bs[n]&1){
ans.insert(ans.begin()+n, ++cur);
}
n--;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
600 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |