#include "perm.h"
using namespace std;
std::vector<int> construct_permutation(long long k)
{
long long cur = 1;
vector<int> res;
for (int i = 0;; i++)
{
int exp = 0;
int power2 = 1;
while (cur + power2 * 2 <= k && (exp + 1) <= i)
{
power2 *= 2;
exp++;
}
cur += power2;
res.insert(res.begin() + exp, i);
if (cur == k)
break;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Execution timed out |
1096 ms |
620 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |