Submission #974885

#TimeUsernameProblemLanguageResultExecution timeMemory
974885AlperenT_Permutation (APIO22_perm)C++17
91.33 / 100
2 ms592 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...