제출 #913808

#제출 시각아이디문제언어결과실행 시간메모리
913808AbdelmagedNour순열 (APIO22_perm)C++17
100 / 100
2 ms604 KiB
#include <bits/stdc++.h> #include "perm.h" #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; vector<int>construct_permutation(ll x){ if(x<=3)return x==1?vector<int>{}:(x==2?vector<int>{0}:vector<int>{1,0}); auto ans=construct_permutation(x/4); int n=ans.size(); if((x&3)==0){ans.insert(ans.end(),{n,n+1});} if((x&3)==1){ans.insert(ans.end(),{n,n+1,-1});} if((x&3)==2){ans.insert(ans.end(),{n,-1,n+1});} if((x&3)==3){ int zero=find(ans.begin(),ans.end(),0)-ans.begin(),one=find(ans.begin(),ans.end(),1)-ans.begin(); if(one<zero)ans[one]--,ans[zero]--,ans.insert(ans.end(),{n,n+1,1}); else ans.insert(ans.end(),{n,-1,n+1,-2}); } int mn=*min_element(ans.begin(),ans.end()); for(auto&c:ans)c-=mn; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...