Submission #699855

#TimeUsernameProblemLanguageResultExecution timeMemory
699855sharaelongPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; vector<int> construct_permutation(ll k) { int pow = 0; while ((1ll << pow) <= k) pow++; pow--; int cnt = pow; vector<int> arr(pow, -1); for (int i=pow-1; i>=0; --i) { if (k & (1ll << i)) { arr[i] = pow++; } } vector<int> ret; for (int i=0; i<arr.size(); ++i) { if (arr[i] != -1) ret.push_back(arr[i]); ret.push_back(i); } return ret; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
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<arr.size(); ++i) {
      |                   ~^~~~~~~~~~~
perm.cpp:12:9: warning: unused variable 'cnt' [-Wunused-variable]
   12 |     int cnt = pow;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...