Submission #725281

#TimeUsernameProblemLanguageResultExecution timeMemory
725281Nahian9696Permutation (APIO22_perm)C++17
71.22 / 100
12 ms1108 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; // #define int long long #define f0(i, n) for(int i = 0; i < (n); i++) #define f1(i, n) for(int i = 1; i <= (n); i++) #define ff first #define ss second #define pb push_back std::vector<int> construct_permutation(long long k) { vector<int> res; // if (k <= 90) { // f0(i, k-1) res.pb(k-2-i); // return res; // } k--; long long cur = -1; while(k > 0) { long long m = 0; long long po = 1; while(2*po - 1 <= k) { po *= 2; m++; } k -= (po-1); for(long long i = m; i > 0; i--) res.pb(cur+i); cur += m; } return vector(res.rbegin(), res.rend()); return {}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...