# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
983875 | avighna | Permutation (APIO22_perm) | C++17 | 3 ms | 504 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 <set>
#include <map>
#include <deque>
#include "perm.h"
typedef long long ll;
ll fsb(ll x) {
for (ll i = 63; i >= 0; -- i) {
if (x & (1LL << i)) {
return i;
}
}
return -1;
}
std::vector<int> construct_permutation(long long x) {
std::deque<ll> ans;
ll bit = fsb(x);
for (ll i = 0; i < bit; ++ i) {
ans.push_back(i);
}
for (ll i = bit - 1; i >= 0; -- i) {
if (x & (1LL << i)) {
ans.push_front(bit - i - 1);
}
}
for (auto &i : ans) {
i *= 1000;
}
std::set<ll> st;
for (ll i = ans.size() - 1; i >= 0; -- i) {
while (st.count(ans[i])) {
ans[i]++;
}
st.insert(ans[i]);
}
std::map<ll, ll> mp;
auto it = st.begin();
for (ll j = 0; j < ans.size(); ++ j) {
mp[*it] = j;
it++;
}
std::vector<int> ret;
for (auto &i : ans) {
ret.push_back(mp[i]);
}
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |