Submission #979044

# Submission time Handle Problem Language Result Execution time Memory
979044 2024-05-10T07:04:01 Z rshohruh Permutation (APIO22_perm) C++17
0 / 100
1 ms 348 KB
#include "perm.h"
#include "bits/stdc++.h"
using namespace std;
int count_zeros(long long k){
    return k ? ((k&1)^1) + count_zeros(k>>1) : 0;
}
vector<int> construct_permutation(long long k){
    --k;
    vector<int> a;
    while(count_zeros(k - ((1LL<<a.size())-1)) > a.size())
        a.push_back(a.size());
    k -= (1LL<<a.size()) - 1;
    for(int i = 0; k > 0; ++ i){
        if((k>>i)&1){
            a.insert(a.begin()+i, a.size());
            k -= 1ll<<i;
        }
    }
    return a;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:10:48: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     while(count_zeros(k - ((1LL<<a.size())-1)) > a.size())
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -