Submission #1040721

#TimeUsernameProblemLanguageResultExecution timeMemory
1040721MarwenElarbiPermutation (APIO22_perm)C++17
0 / 100
0 ms604 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 = 63; i >= 0; --i) { if(k>=(1ll<<i)){ k-=(1ll<<i); tab.pb(i+1); cnt+=i+1; } } vector<int> ans; for (int i = 0; i < tab.size(); ++i) { for (int j = cnt-tab[i]+1; 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...