Submission #573143

#TimeUsernameProblemLanguageResultExecution timeMemory
573143dqhungdlPermutation (APIO22_perm)C++17
91.33 / 100
2 ms352 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; int getBit(long long x, int k) { return (x >> k) & 1LL; } vector<int> construct_permutation(long long k) { if (!k) return {}; int last = 0; for (int i = 0; i <= 60; i++) if (getBit(k, i)) last = i; vector<int> rs(last); iota(rs.begin(), rs.end(), 0); for (int i = last - 1; i >= 0; i--) if (getBit(k, i)) { for (int j = i; j < rs.size(); j++) rs[j]++; rs.push_back(i); } // for (int x: rs) // cout << x << ' '; // cout << '\n'; return rs; }

Compilation message (stderr)

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