#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k)
{
int m = __lg(k) + 1;
vector<int> zero(m + 1);
int pad = 0;
for (int j = 0; j <= m; j++) {
if (k & (1ll << j)) {
zero[m - j - 1] = ++pad;
}
}
vector<int> ans;
for (int i = 1; i < m; i++) {
ans.push_back(i + pad - 2);
if (zero[i]) ans.push_back(zero[i] - 1);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Partially correct |
1 ms |
348 KB |
Partially correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Partially correct |
1 ms |
344 KB |
Partially correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Partially correct |
2 ms |
344 KB |
Partially correct |
11 |
Partially correct |
2 ms |
348 KB |
Partially correct |
12 |
Partially correct |
1 ms |
344 KB |
Partially correct |
13 |
Partially correct |
2 ms |
348 KB |
Partially correct |