Submission #745385

#TimeUsernameProblemLanguageResultExecution timeMemory
745385PatrickPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; using ll = long long; std::vector<int> construct_permutation(long long k) { ll v = 1; ll a = 0; while (v * 2 <= k) { v *= 2; a++; } k -= v; vector<int> inc(a); while (k > 0) { ll s = 0; while ((1LL << (s + 1)) <= k) { s++; } inc[s] = a++; k -= (1LL << s); } vector<int> ans; for (int i = 0; i < inc.size(); i++) { if (inc[i] != 0) ans.push_back(inc[i]); ans.push_back(i); } return ans; }

Compilation message (stderr)

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