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>
#include "perm.h"
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ =4e5+100, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353;
ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k;
ll gcd(ll x,ll y){
if(!y)return x;
return gcd(y,x%y);
}
ll dp[301],pre[301];
vector<int> construct_permutation(long long k){
vector<int>res,A;
res.push_back(0);
dp[0]=1;
for(int i=0;i<=300;i++)pre[i]++;
x=k-1;
sum=1;
while(1){
if(sum==x)break;
for(int i=res.size();i>=0;i--){
ll bef;
bef=i?pre[i-1]:0;
if(bef+1+sum<=x){
sum+=bef+1;
for(int j=300;j>i;j--)dp[j]=dp[j-1];
dp[i]=bef+1;
pre[0]=dp[0];
for(int j=1;j<=300;j++)pre[j]=pre[j-1]+dp[j];
for(auto &j:res)j=i<=j?j+1:j;
res.push_back(i);
break;
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |