# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064981 | sammyuri | Permutation (APIO22_perm) | C++17 | 4 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;
typedef long long ll;
std::vector<int> construct_permutation(long long k) {
// build initial permutation
ll curpow = 2;
vector<int> ans = {0};
while (curpow * 2 <= k) {
curpow *= 2;
ans.push_back(ans.back() + 1);
}
if (curpow == k)
return ans;
// start adding extras
k -= curpow;
while (k) {
curpow = 1;
int i = 0;
while (curpow * 2 <= k) {
curpow *= 2;
i ++;
}
k -= curpow;
vector<int> newans;
int seen = 0;
if (i == 0) newans.push_back(-1);
for (auto a : ans) {
newans.push_back(a);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |