# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575240 | AJ00 | Permutation (APIO22_perm) | C++17 | 2 ms | 340 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 <bits/stdc++.h>
using namespace std;
int n;
const int MOD = 1000000007;
vector<int> construct_permutation(long long int k){
vector<int> ans,op;
ans.push_back(0);
if (k == 2){
return ans;
}
// cerr << dp[k] << "\n";
long long int cur = k;
while (cur != 2){
if (cur%2==0){
op.push_back(2);
cur = (cur/2);
}
else {
op.push_back(1);
cur--;
}
}
reverse(op.begin(),op.end());
int maxm = 0,minm=0;
for (int e: op){
if (e == 2){
++maxm;
ans.push_back(maxm);
}
else {
--minm;
ans.push_back(minm);
}
}
for (int i = 0; i < ans.size(); i++){
ans[i] += abs(minm);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |