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 <bits/stdc++.h>
#include "perm.h"
#define int long long
using namespace std;
vector<int32_t> construct_permutation(int k) {
deque<int> ans;
k--;
while (k > 0) {
if (1LL & k) {
ans.push_back(0);
k = (k >> 1LL);
} else {
ans.push_back(1);
k--;
}
}
int curr = 0;
int t = ans.size();
vector<int32_t> tans(t);
for (int i = 0; i < t; i++) {
if (ans[i] == 0) tans[i] = (curr++);
}
for (int i = t - 1; i >= 0; i--) {
if (ans[i] == 1) tans[i] = (curr++);
}
for (auto u : tans) cout << u << " ";
cout << "\n";
return tans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |