제출 #745171

#제출 시각아이디문제언어결과실행 시간메모리
745171Dan4Life순열 (APIO22_perm)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb push_back #define all(a) begin(a), end(a) vector<int> construct_permutation(ll n) { vector<double> v; v.clear(); vector<int> A,D; A.clear(); D.clear(); while(n>0) D.pb(n%4),n/=4; reverse(all(D)); int cnt = 0; int T=0, k=0, X = -1; double t3 = 1.5; for(auto u : D){ if(!cnt){ if(u==2) v.pb(0),T=1; else if(u==3) v.pb(1), v.pb(0),T=2, k=1; cnt = 1; } else{ if(u==0) v.pb(T++), v.pb(T++); else if(u==1) v.pb(T++), v.pb(T++), v.pb(X--); else if(u==2) v.pb(T++), v.pb(X--), v.pb(T++); else if(k) v.pb(T++), v.pb(T++), v.pb(t3); else v.pb(T++), v.pb(X--), v.pb(T++), v.pb(X--), t3=X+2.5, k=1; } } //0 1 2 3 4 -1 5 -2 auto w = v; sort(all(w)); for(auto u : v) A.pb(lower_bound(all(w),u)-begin(w)); return A; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...