Submission #912277

# Submission time Handle Problem Language Result Execution time Memory
912277 2024-01-19T09:23:38 Z TienDungz Permutation (APIO22_perm) C++17
0 / 100
0 ms 348 KB
// #include "perm.h"
#include <bits/stdc++.h> 
using namespace std;

std::vector<int> construct_permutation(long long n)
{
    vector<int> res;
    bool ok = true;
    int p = 0;
    for (int j = 60; j >= 0; j--) {
        int m = 1LL << j;
        if (n - m >= 0) {
            n -=m;
            if (ok) {
                ok = false;
                for (int i = 1; i <= j; i++) {
                    res.push_back(2 * i);
                }
                p = j;
            } else {
                res.push_back(2 * j + 1);
            }
        }
    }
    return res;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:9:9: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    9 |     int p = 0;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer 120 violates the range [0, 119]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer 120 violates the range [0, 119]
2 Halted 0 ms 0 KB -