Submission #872721

#TimeUsernameProblemLanguageResultExecution timeMemory
872721salmonPermutation (APIO22_perm)C++17
0 / 100
1 ms348 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k){ vector<int> v; deque<int> dq; vector<int> bits; int cont = 0; int ze = 1; while(k != 0){ bits.push_back(k % 2); k /= 2; } bits.pop_back(); reverse(bits.begin(),bits.end()); for(int i = 0; i < bits.size(); i++){ if(bits[i] == 1 && i < bits.size() - 1 && bits[i + 1] == 1){ dq.push_front(cont - 1); dq.push_front(ze); dq.push_front(cont); ze++; cont -= 2; i++; } else if(bits[i] == 1){ dq.push_front(cont); dq.push_back(cont - 1); cont -= 2; } else{ dq.push_front(cont); cont--; } } cont++; for(int i : dq){ v.push_back(i - cont); } return v; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < bits.size(); i++){
      |                    ~~^~~~~~~~~~~~~
perm.cpp:24:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(bits[i] == 1 && i < bits.size() - 1 && bits[i + 1] == 1){
      |                            ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...