Submission #1083818

#TimeUsernameProblemLanguageResultExecution timeMemory
1083818alexander707070Permutation (APIO22_perm)C++17
91.33 / 100
2 ms496 KiB
#include<bits/stdc++.h> #define MAXN 200007 using namespace std; int num; deque<int> perm; vector<int> ans,w; bool fr; void mult(){ perm.push_back(num); num++; } void add(){ perm.push_front(num); num++; } void reset(){ fr=false; num=0; perm.clear(); ans.clear(); } vector<int> construct_permutation(long long k){ reset(); for(int i=62;i>=0;i--){ if((1LL<<i)>k)continue; if(((1LL<<i)&k)>0 and fr){ add(); }else if(((1LL<<i)&k)>0)fr=true; if(i>0)mult(); } for(int i=0;i<perm.size();i++){ ans.push_back(perm[i]); } return ans; } /*int main(){ w=construct_permutation(5); for(int i:w)cout<<i<<" "; }*/

Compilation message (stderr)

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