Submission #874126

#TimeUsernameProblemLanguageResultExecution timeMemory
874126green_gold_dogPermutation (APIO22_perm)C++17
91.33 / 100
2 ms600 KiB
#include<bits/stdc++.h> #include "perm.h" typedef long long ll; using namespace std; std::vector<int> construct_permutation(long long k) { deque<ll> d; d.push_back(0); ll na = 2; vector<ll> bits; while (k) { bits.push_back(k % 2); k /= 2; } bits.pop_back(); bool b = false; ll now = 1; while (!bits.empty()) { if (b) { d.push_back(now); now++; } b = true; if (bits.back()) { d.push_front(now); now++; } bits.pop_back(); } vector<int> ans; for (auto i : d) { ans.push_back(i); } return ans; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:10:12: warning: unused variable 'na' [-Wunused-variable]
   10 |         ll na = 2;
      |            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...