Submission #1357469

#TimeUsernameProblemLanguageResultExecution timeMemory
1357469kawhietPermutation (APIO22_perm)C++20
91.33 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#include "perm.h"
using namespace std;

vector<int> construct_permutation(long long k) {
    int l = 1, r = 5000;
    vector<int> a;
    while (k > 1) {
        if (k & 1) {
            k--;
            a.push_back(r--);
        } else {
            k /= 2;
            a.push_back(l++);
        }
    }
    vector<int> b = a;
    ranges::sort(b);
    for (auto &x : a) {
        x = ranges::lower_bound(b, x) - b.begin();
    }
    return a;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...