Submission #1040748

#TimeUsernameProblemLanguageResultExecution timeMemory
1040748MarwenElarbiPermutation (APIO22_perm)C++17
71.22 / 100
10 ms1372 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; #define pb push_back std::vector<int> construct_permutation(long long k) { k--; vector<int> tab; int cnt=0; for (int i = 62; i > 0; --i) { while(k>=(1LL<<i)-1){ k-=(1LL<<i)-1; tab.pb(i); cnt+=i; } } vector<int> ans; for (int i = 0; i < tab.size(); ++i) { for (int j = cnt-tab[i]; j < cnt; ++j) { ans.pb(j); } cnt-=tab[i]; } return ans; }

Compilation message (stderr)

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