Submission #742328

#TimeUsernameProblemLanguageResultExecution timeMemory
742328khshgPermutation (APIO22_perm)C++17
91.33 / 100
2 ms376 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<ld, ld>; #define mp make_pair #define ff first #define ss second template<class T> using V = vector<T>; #define arr array using vi = V<int>; using vb = V<bool>; using vl = V<ll>; using vd = V<ld>; using vs = V<str>; using vpi = V<pi>; using vpl = V<pl>; using vpd = V<pd>; #define sz(x) (int)((x).size()) #define bg(x) begin(x) #define all(x) bg(x), end(x) #define rall(x) (x).rbegin(), (x).rend() #define sor(x) sort(all(x)) #define rsz resize #define ins insert #define pb push_back #define eb emplace_back #define ft front() #define bk back() #define lb lower_bound #define ub upper_bound #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for(int i = (b) - 1; i >= (a); --i) #define R0F(i, a) ROF(i, 0, a) #define rep(a) F0R(_, a) #define trav(a, x) for(auto& a : x) template<class T> bool ckmin(T& a, const T& b) { return (b < a ? a = b, 1 : 0); } template<class T> bool ckmax(T& a, const T& b) { return (b > a ? a = b, 1 : 0); } vi construct_permutation(ll k) { vb bits; F0R(i, 62) { bits.eb((k >> i) & 1LL); } while(!bits.bk) bits.pop_back(); bits.pop_back(); reverse(all(bits)); vi ans; int mn = 0, mx = 1; F0R(i, sz(bits)) { bool cur = bits[i]; if(cur) { ans.push_back(mx); ans.push_back(mn); ++mx; --mn; } else { ans.push_back(mx); ++mx; } } mn = 0x3f3f3f3f; trav(u, ans) ckmin(mn, u); trav(u, ans) u -= mn; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...