Submission #1200081

#TimeUsernameProblemLanguageResultExecution timeMemory
1200081browntoadPermutation (APIO22_perm)C++20
82.38 / 100
4 ms840 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define ll long long // #define int ll #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, n+1) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define pii pair<int, int> #define f first #define s second #define pb push_back #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) namespace{ const ll maxn = 1e5+5; const ll mod = 1e9+7; const ll inf = (1ll<<60); } std::vector<int> construct_permutation(long long k){ k--; // imma make it a bunch of sums vector<int> ret; // initially all reversed int cur = 0; for (int b = 55; b >= 0; b -= 5){ ll tmp = (1ll<<b); int cnt = 0; while(tmp * (cnt+1) - 1 <= k){ cnt++; } if (cnt == 0) continue; cnt--; k -= tmp * (cnt+1) - 1; vector<int> ra, rb; REP(i, b){ ra.pb(cur++); } REP(i, cnt){ rb.pb(cur++); } REP(i, SZ(rb)) ret.pb(rb[i]); RREP(i, SZ(ra)) ret.pb(ra[i]); } reverse(ALL(ret)); return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...