Submission #1113096

#TimeUsernameProblemLanguageResultExecution timeMemory
1113096lucascgarPermutation (APIO22_perm)C++17
91.33 / 100
2 ms604 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...