Submission #985136

#TimeUsernameProblemLanguageResultExecution timeMemory
985136vjudge1Permutation (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; //#define int long long #define pb push_back #define pii pair<int,int> #define ss second #define ff first #define debu(x) (cerr << #x << " = "<< x << "\n") std::vector<int> construct_permutation(long long k) { //cout << "k is " << k << "\n"; #define int long long vector<int32_t>ans; int ochako=0; int got = 0; for (int a = 63; a >= 0; a--) { if (((((int)1) << a) & (k))) { //cout << "ak " << a << " " << k << "\n"; if (!ochako) { got = a - 1; ochako = a; for (int b = 0; b < a; b++) { ans.pb(b); } } } } //cout << ochako << "ochako\n"; for (int a = ochako-1; a >= 0; a--) { //cout << "once " << a << "\n"; if (((((int)1) << a) & (k))) { got++; ans.insert(ans.begin() + a, got); } } /*cout << "outputting the arr:\n"; for (int x : ans) { cout << x << " "; } cout << "dante\n";*/ #undef int return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...