This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define ld long double
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define ll long long
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
#define deb(x) cout <<#x << " : " << x << "\n" ;
using namespace std ;
const int maxn = 2e6 + 10 , maxq = 32, inf = 1e9+10 , lg = 19 ,sq = 1000 ,mod = 998244353 ;
ll dp[maxn] ;
vector<int> construct_permutation(ll k){
k -- ;
vector <int> ans ;
int c= 0 ;
while(k){
ll t = 1;
int id =sz(ans) ;
rep(i ,0 , sz(ans)-1){
if(t+dp[ans[i]] <= k){
t += dp[ans[i]] ;
}else{
id = i ;
break;
}
}
ans.pb(0);
per(i , sz(ans)-2 , id){
swap(ans[i] , ans[i+1]) ;
}
k-=t;
dp[c] =t ;
ans[id] = c ;
c++;
}
return ans ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |