Submission #737379

#TimeUsernameProblemLanguageResultExecution timeMemory
737379becaidoPermutation (APIO22_perm)C++17
100 / 100
3 ms340 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> #include "perm.h" using namespace std; #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second vector<int> construct_permutation(ll k) { vector<int> ans; vector<pair<int, int>> p; int m = __lg(k); FOR (i, 0, m - 1) p.pb(2 * i, 10000 + i); k -= 1ll << m; int cnt = 0, mn = 100, smn = 100; for (int i = m; i >= 0; i--) if (k >> i & 1) { if (i > 0 && k >> (i - 1) & 1 && cnt >= 2) { p.pb(2 * (m - i) + 1, smn + i); i--; } else { p.pb(2 * (m - i) - 1, 100 * i); smn = mn, mn = 100 * i; cnt++; } } vector<int> lis; for (auto [pos, val] : p) lis.pb(val); sort(lis.begin(), lis.end()); sort(p.begin(), p.end()); for (auto [pos, val] : p) ans.pb(lower_bound(lis.begin(), lis.end(), val) - lis.begin()); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...