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;
/*
*/
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;
const int MAXN = 2e5+10;
vector<int> construct_permutation(long long k){
vector<int> ans;
int cr = 0, big = 100000;
if ((k&1)){
ans.push_back(big);
big--;
}
for (long long i=2;i<=k;i<<=1){
ans.push_back(cr);
cr++;
if (2*i <= k && ((k&i) != 0)){
ans.push_back(big);
big--;
}
}
for (int i=ans.size()-1;i>=0;i--){
if (ans[i]>cr){
ans[i] = cr, cr++;
}
}
return ans;
}
// signed main(){
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
// long long n;
// cin >> n;
// vector<int> ans = construct_permutation(n);
// cout << ans.size() << '\n';
// for (auto &x:ans) cout << x << ' ';
// cout << '\n';
// return 0;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |