Submission #717970

#TimeUsernameProblemLanguageResultExecution timeMemory
717970125259Permutation (APIO22_perm)C++17
91.33 / 100
3 ms432 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<long long>num; void start(){ long long cnt=1; for(int i=0; i<63; i++){ num.push_back(cnt); cnt*=2; } return; } vector<int> construct_permutation(long long k){ start(); vector<int>v; for(int i=62; i>=0; i--){ if(k>=num[i]){ v.push_back(i); k-=num[i]; } } sort(v.begin(),v.end()); vector<int>vec; int cnt=v.back()+v.size()-2; int cnt1=0; for(int i=0; i<v.size()-1; i++){ while(cnt1<v[i]){ vec.push_back(cnt1); cnt1++; } vec.push_back(cnt); cnt--; } while(cnt1<v.back()){ vec.push_back(cnt1); cnt1++; } return vec; }

Compilation message (stderr)

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