# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
605423 | AugustinasJucas | Permutation (APIO22_perm) | C++17 | 2 ms | 384 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<int> init;
int ind = 0;
long long liko = 0;
for(int i = 0; i < 64; i++) {
long long bus = (1ll << i);
if(bus > k) {
// desim i-1 tu.
for(int j = 0; j < i-1; j++) init.push_back(ind++);
liko = k - (1ll << (i-1));
break;
}
}
// cout << "liko = " << liko << ", popcnt = " << __builtin_popcount(liko) << endl;
vector<int> ret;
ind += __builtin_popcountll(liko) - 1;
for(int i = 0; i < init.size(); i++) {
if((1ll << i) & liko) {
ret.push_back(ind);
ind--;
}
ret.push_back(init[i]);
}
// cout << "ret = "; for(auto x : ret) cout << x << " ";
//cout << endl;
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |