#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
vector<int> construct_permutation(long long k){
vector<int> ans;
int cnt = 0; k--;
for(int i = 59; i >= 0; i--){
if(k >= (1ll<<(i+1)) - 1){
int lcnt = cnt;
cnt += i + 1;
k -= (1ll<<(i+1)) - 1;
for(int i = cnt; i > lcnt; i--){
ans.push_back(i - 1);
}
}
}
if(k) ans.push_back(cnt);
reverse(ans.begin(), ans.end());
return ans;
}
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |