Submission #572916

#TimeUsernameProblemLanguageResultExecution timeMemory
572916moday_morningPermutation (APIO22_perm)C++17
0 / 100
1 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> #define ll long long using namespace std; vector<int> construct_permutation(ll k) { // 90 balls vector <int> ans; vector <int> bytes; for (int i = 63; i >= 1; i--) { if (k & (1ll << i) != 0) { bytes.push_back(i); } } int mx = bytes[0]; for (int i = 0; i < mx; i++) { ans.push_back(i); } for (int i = 1; i < bytes.size(); i++) { int cur_bit = bytes[i]; for (int j = 0; j < ans.size(); j++) { if (ans[j] >= cur_bit) { ans[j]++; } } } if (k % 2) { 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:12:28: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   12 |         if (k & (1ll << i) != 0) {
      |                 ~~~~~~~~~~~^~~~
perm.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 1; i < bytes.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
perm.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = 0; j < ans.size(); j++) {
      |                         ~~^~~~~~~~~~~~
perm.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int j = 0; j < ans.size(); j++) {
      |                         ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...