# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011598 | dimashhh | Permutation (APIO22_perm) | C++17 | 1 ms | 604 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;
vector<int> ret,g;
int hsb(ll x){
for(int i = 60;i >= 0;i--){
if((x >> i) & 1) return i;
}
}
vector<int> construct_permutation(long long k)
{
ret.clear();
g.clear();
int f = hsb(k);
for(int i = 0;i < f;i++){
g.push_back(i);
}
for(int i = f - 1;i >= 0;i--){
if((k >> i) & 1){
for(int j = i;j < (int)g.size();j++){
g[j]++;
}
for(int j = 0;j < (int)ret.size();j++){
if(ret[j] >= g[i] - 1){
ret[j]++;
}
}
ret.push_back(g[i] - 1);
}
}
for(int j:ret){
g.push_back(j);
}
// for(int j:g){
// cout << j << ' ';
// }
return g;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |