제출 #710003

#제출 시각아이디문제언어결과실행 시간메모리
710003Astrayt순열 (APIO22_perm)C++17
91.33 / 100
3 ms392 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back vector<int> construct_permutation(ll k){ int len = 1; while((1ll << len) < k) len++; vector<int> ans, tmp; for(int i = 1; i < len; ++i){ ans.pb(2 * i); } k -= (1ll << (len - 1)); for(int cur = 2 * len - 1, pw = 0; cur >= 1; cur -= 2, pw++){ if(k & (1ll << pw)) tmp.pb(cur); } for(auto x:ans) tmp.pb(x); swap(ans, tmp); vector<int> ls = ans; sort(ls.begin(), ls.end()); for(auto &x:ans){ x = lower_bound(ls.begin(), ls.end(), x) - ls.begin(); } return ans; } /* int main(){ int q; cin >> q; while(q--){ int k; cin >> k; vector<int> v = construct_permutation(k); for(auto x:v) cout << x << ' '; cout << '\n'; } } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...