Submission #931281

#TimeUsernameProblemLanguageResultExecution timeMemory
931281djs100201Permutation (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#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[101],pre[101]; vector<int> construct_permutation(long long k){ vector<int>res,A; res.push_back(0); dp[0]=1; for(int i=0;i<=100;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=100;j>i;j--)dp[j]=dp[j-1]; dp[i]=bef+1; pre[0]=dp[0]; for(int j=1;j<=100;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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...