제출 #580252

#제출 시각아이디문제언어결과실행 시간메모리
580252CaroLinda순열 (APIO22_perm)C++17
100 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> #define lp(i,a,b) for(int i = a ; i < b ;i++ ) #define pb push_back #define ll long long #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define mk make_pair #define ff first #define ss second #define pii pair<int,int> using namespace std ; vector<int> solve(ll n){ if(n == 3) return {2,1}; if(n == 4) return {3,2,1}; if(n == 5) return {3,1,2}; if(n == 7) return {3,2,4,1}; if(n == 11) return {5,3,1,2,4}; if(n == 15) return {7, 6, 5, 2, 1, 3, 4}; if(n%4 == 3){ vector<int> ret = solve(n/4); ret.push_back(sz(ret)+1); ret.push_back(sz(ret)+1); int nxt = sz(ret)+1; ret.insert(ret.begin()+2, nxt); return ret; } vector<int> ret = solve(n/2); ret.push_back(sz(ret)+1); if(n&1LL){ for(auto &e : ret) e++; ret.push_back(1); } return ret; } vector<int> construct_permutation(long long k) { if(k == 2) return {0}; vector<int> ret = solve(k) ; for(auto &e : ret ) --e ; return ret ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...