Submission #575916

#TimeUsernameProblemLanguageResultExecution timeMemory
575916SHZhangPermutation (APIO22_perm)C++17
91.33 / 100
3 ms356 KiB
#include "perm.h" using namespace std; #define ll long long vector<int> construct_permutation(ll k) { ll maxbit = 0; for (ll i = 62; i >= 0; i--) { if (k & (1LL << i)) { maxbit = i; break; } } vector<int> ops; for (ll i = maxbit - 1; i >= 0; i--) { ops.push_back(0); if (k & (1LL << i)) ops.push_back(1); } vector<int> ans; for (int i = 0; i < ops.size(); i++) { if (ops[i] == 0) { ans.push_back((int)ans.size()); } else { for (int j = 0; j < ans.size(); j++) ans[j]++; ans.push_back(0); } } return ans; }

Compilation message (stderr)

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