Submission #850015

#TimeUsernameProblemLanguageResultExecution timeMemory
850015AndreyPermutation (APIO22_perm)C++17
91.33 / 100
2 ms760 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { vector<int> ans(0); long long br = 2,y = 0; while(br <= k) { ans.push_back(y); y++; br*=2; } k-=br/2; for(long long i = y; i >= 0; i--) { if((1LL << i) <= k) { k-=(1LL << i); ans.push_back(i); for(int j = 0; j < ans.size()-1; j++) { if(ans[j] >= i) { ans[j]++; } } } } return ans; }

Compilation message (stderr)

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