Submission #820943

#TimeUsernameProblemLanguageResultExecution timeMemory
820943HanksburgerPermutation (APIO22_perm)C++17
71.22 / 100
11 ms1108 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> vec, ans; vector<int> construct_permutation(long long k) { vec.clear(); ans.clear(); for (long long i=59; i>=1; i--) { while (k>(1LL<<i)-1) { k-=(1LL<<i)-1; vec.push_back(i); } } long long sum=0; for (long long i=0; i<vec.size(); i++) { for (long long j=sum+vec[i]-1; j>=sum; j--) ans.push_back(j); sum+=vec[i]; } reverse(ans.begin(), ans.end()); return ans; }

Compilation message (stderr)

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