Submission #984111

#TimeUsernameProblemLanguageResultExecution timeMemory
984111vjudge1Permutation (APIO22_perm)C++17
65.28 / 100
11 ms1372 KiB
#include "perm.h" #include<bits/stdc++.h> #define sz size() #define ll long long using namespace std; mt19937_64 rnd(2983101); vector<int> construct_permutation(ll k) { ll z = 1, sum = 0; --k; vector<ll> x; for(ll t = 1; t <= 100; ++t) for(ll j = 59; j >= 0; --j) { if((z << j) - 1 > k) continue; x.push_back(j); k -= (z << j) - 1; sum += j; } for(ll st = 0; st <= 1000; ++st) { vector<ll> _x; ll _k = k; ll cnt = 0; for(ll t = 1; t <= 500 && _k > 0; ++t) { ll mx = (63ll - __builtin_clzll(_k)); ll m = rnd() % mx; ++m; if((1ll << m) > _k) continue; _k -= (1ll << m); _x.push_back(m); cnt += m; } if(cnt > 0 && cnt < sum) sum = cnt, x = _x; } reverse(x.begin(), x.end()); ll cur = 0; vector<int> ans; for(ll t : x) { for(ll i = cur + t; i > cur; --i) ans.push_back(i - 1); cur += t; } reverse(ans.begin(), ans.end()); return ans; } //signed main() //{ // ios_base::sync_with_stdio(0); // cin.tie(0), cout.tie(0); // ll n; // cin >> n; // for(auto i : construct_permutation(n)) // cout << i << ' '; //}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...