Submission #912363

# Submission time Handle Problem Language Result Execution time Memory
912363 2024-01-19T10:23:01 Z huyngo Permutation (APIO22_perm) C++17
0 / 100
0 ms 348 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);
        }
        };
    for (auto& x : a)
        x -= (dd - 1);
    return a;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:7:10: warning: variable 'work' set but not used [-Wunused-but-set-variable]
    7 |     auto work = [&](auto self, long long x) -> void {
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer 0 violates the range [1, 5000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer 0 violates the range [1, 5000]
2 Halted 0 ms 0 KB -