# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962749 | 0npata | Permutation (APIO22_perm) | C++17 | 2 ms | 348 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;
#define vec vector
#define ll long long
std::vector<int> construct_permutation(ll k)
{
// cerr << "k: " << k << '\n';
vec<ll> bp(0);
vec<int> ans(0);
for(ll i = 0; i<64; i++) {
if((((ll)1)<<i) & k) {
bp.push_back(i);
}
}
int lb = bp.back();
bp.pop_back();
// cerr << "lb : " << lb << '\n';
int cur = 0;
int j = 0;
vec<int> right(0);
vec<int> left(0);
for(int i = 0; i<lb; i++) {
if(bp[j] == i) {
right.push_back(cur);
cur++;
j++;
}
left.push_back(cur);
cur++;
}
reverse(right.begin(), right.end());
for(int i = 0; i<left.size(); i++) ans.push_back(left[i]);
for(int i = 0; i<right.size(); i++) ans.push_back(right[i]);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |