#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> construct_permutation(long long k)
{
vector<long long> logs;
int L = 0;
for(long long i = 0; i <= log(k) * 2; i ++){
long long x = pow(2, i);
if(x <= k) {
logs.push_back(x);
L = i;
} else {
break;
}
}
//cout << logs[logs.size()-1];
vector<int> res(L, 0);
k -= logs[logs.size()-1];
//int x = log(k+1) / log(2) + 1;
iota(res.begin(), res.end(), 0);
while(k > 0){
for(long long i = logs.size() - 1; i >= 0; i --){
if(logs[i] <= k){
res.insert(res.begin() + i, L);
k -= logs[i];
break;
}
}
L += 1;
}
/*for(int i = 0; i < res.size(); i ++){
cout << res[i] << " ";
}*/
return res;
}
/*
g++ -std=gnu++17 -Wall -O2 -static -o perm grader.cpp perm.cpp
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Partially correct |
1 ms |
340 KB |
Partially correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Partially correct |
2 ms |
340 KB |
Partially correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Partially correct |
2 ms |
340 KB |
Partially correct |
11 |
Partially correct |
2 ms |
340 KB |
Partially correct |
12 |
Partially correct |
2 ms |
300 KB |
Partially correct |
13 |
Partially correct |
2 ms |
340 KB |
Partially correct |