Submission #572702

#TimeUsernameProblemLanguageResultExecution timeMemory
572702baluteshihPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back

vector<int> construct_permutation(ll k) {
    if (k == 1)
        return {};
    if (k == 2)
        return {0};
    if (k & 1) {
        vector<int> rt = construct_permutation(k - 1);
        for (int &i : rt)
            ++i;
        rt.pb(0);
        return rt;
    }
    vector<int> rt = construct_permutation(k / 2);
    rt.pb(SZ(rt));
    return rt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...