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 <iostream>
#include <vector>
using namespace std;
const int N = 100 + 10;
vector<int> construct_permutation(long long k){
vector<int> ans;
long long o = 1;
for (int i=60;i>=0;i--){
if ((o<<i) & k){
for (int j=1;j<=i;j++)
ans.push_back(j * 1000);
while (i > 0){
i--;
if ((o<<i) & k)
ans.push_back(ans[i] - 500);
}
break;
}
}
int n = ans.size(),cur = 0;
vector<int> seen(n,0);
while (cur < n){
int ind = 0;
for (int i=0;i<n;i++)
if (!seen[i] and (seen[ind] or ans[i] < ans[ind]))
ind = i;
ans[ind] = cur++;
seen[ind] = 1;
}
return ans;
}
// signed main(){
// long long k;
// cin>>k;
// vector<int> ans = construct_permutation(k);
// for (int i : ans)
// cout<<i<<' ';
// cout<<'\n';
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |