Submission #982950

#TimeUsernameProblemLanguageResultExecution timeMemory
982950Muhammad_AneeqPermutation (APIO22_perm)C++17
91.33 / 100
2 ms516 KiB
#include "perm.h" #include <vector> #include <algorithm> using namespace std; vector<int> construct_permutation(long long k) { vector<int>bits; for (int i=59;i>=0;i--) { if ((1ll<<i)&k) bits.push_back(i); } reverse(begin(bits),end(bits)); int sz=bits.back()+bits.size()-1; int st=0,en=sz-1; vector<int>ans(sz,0); int j=0; for (int i=0;i<sz;i++) { if (j<bits.size()&&bits[j]==st) ans[i]=en--,j++; else ans[i]=st++; } return ans; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:20:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if (j<bits.size()&&bits[j]==st)
      |       ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...