Submission #972133

#TimeUsernameProblemLanguageResultExecution timeMemory
972133tamir1Permutation (APIO22_perm)C++17
71.22 / 100
10 ms1116 KiB
#include "perm.h" #include <iostream> #define ll long long using namespace std; vector<int> construct_permutation(long long k) { ll t=0,i,j,sum=0,idx=0; k--; vector<ll> v,u; while(true){ if(t>k) break; v.push_back(t); t=t*2+1; } while(k>0){ for(i=v.size()-1;i>=0;i--){ if(v[i]<=k){ u.push_back(i); k-=v[i]; break; } } } for(i=0;i<u.size();i++) sum+=u[i]; vector<int> ans(sum); for(i=u.size()-1;i>=0;i--){ for(j=sum-u[i];j<sum;j++){ ans[j]=idx; idx++; } sum-=u[i]; } return ans; }

Compilation message (stderr)

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