Submission #979047

#TimeUsernameProblemLanguageResultExecution timeMemory
979047sunnatPermutation (APIO22_perm)C++17
0 / 100
1 ms348 KiB
#include <iostream> #include <vector> 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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...