Submission #956109

#TimeUsernameProblemLanguageResultExecution timeMemory
956109OtalpPermutation (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back vector<int> construct_permutation(ll k) { vector<int> ans; int fbit = 0; for(int i=60; i>=0; i--){ if((k & (1ll << i))){ fbit = i; break; } } vector<int> h; for(int i=fbit; i>=0; i--){ if((k & (1ll << i))){ int cnt = 0; for(int j=i-1; j>=0; j--){ cnt++; if((k & (1ll << j))) break; } h.pb(cnt); //cout<<k<<' ' } } for(int i=0; i<h[0]; i++){ ans.pb(i); } int l=0, r=h[0]-1; for(int i=1; i<h.size(); i++){ ans.pb(--l); for(int j=0; j<h[i]; j++){ ans.pb(++r); } } for(int i=0; i<ans.size(); i++){ ans[i] -= l; } for(int i=0; i<ans.size(); i++){ //cout<<ans[i]<<' '; } return ans; }

Compilation message (stderr)

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