Submission #872648

#TimeUsernameProblemLanguageResultExecution timeMemory
872648salmonPermutation (APIO22_perm)C++17
0 / 100
1 ms600 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; while(k != 0){ bits.push_back(k % 2); k /= 2; } reverse(bits.begin(),bits.end()); for(int i = 0; i < bits.size(); i++){ if(bits[i] == 1){ dq.push_front(cont); dq.push_back(cont - 1); cont -= 2; } else{ dq.push_front(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:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0; i < bits.size(); i++){
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...