# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
777308 | yeyso | Permutation (APIO22_perm) | C++17 | 2 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |