Submission #730724

#TimeUsernameProblemLanguageResultExecution timeMemory
730724Magikarp4000Permutation (APIO22_perm)C++17
64.63 / 100
16 ms1492 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define OPTM ios_base::sync_with_stdio(0); cin.tie(0); #define INF int(1e9+7) #define ln '\n' #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define FOR(i,s,n) for (int i = s; i < n; i++) #define FORR(i,n,s) for (int i = n; i > s; i--) #define FORX(u, arr) for (auto u : arr) #define PB push_back #define in(v,x) (v.find(x) != v.end()) #define F first #define S second #define PII pair<int, int> #define PLL pair<ll, ll> #define UM unordered_map #define US unordered_set #define PQ priority_queue #define ALL(v) v.begin(), v.end() const ll LLINF = 1e18+1; std::vector<int> construct_permutation(long long k) { vector<vector<int>> v; ll x = k, cnt = 0, cur = 0, ex = -1; while (x) { if (x%2) { ex++; if (cnt > 0) { vector<int> tmp; FOR(i,0,cnt) tmp.PB(cur++); v.PB(tmp); } } x /= 2; cnt++; } vector<int> tmp; FOR(i,0,ex) tmp.PB(cur++); reverse(ALL(tmp)); v.PB(tmp); reverse(ALL(v)); vector<int> res; FOR(i,0,(int)v.size()) { FORX(u,v[i]) res.PB(u); } // FORX(u,res) cout << u << ' '; // cout << ln; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...