Submission #912366

# Submission time Handle Problem Language Result Execution time Memory
912366 2024-01-19T10:23:40 Z huyngo Permutation (APIO22_perm) C++17
0 / 100
183 ms 262144 KB
#include "perm.h"

std::vector<int> construct_permutation(long long k)
{
    std::vector<int> a;
    long long l = 0, r = 0, dd = 0;
    auto work = [&](auto self, long long x) -> void {
        if (x & 1) {
            a.push_back(--l);
            dd = l;
            self(self, x - 1);
        }
        else {
            a.push_back(++r);
            self(self, x >> 1);
        }
        };
    work(work, k);
    for (auto& x : a)
        x -= (dd - 1);
    return a;
}
# Verdict Execution time Memory Grader output
1 Runtime error 183 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 183 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -