Submission #974884

#TimeUsernameProblemLanguageResultExecution timeMemory
974884AlperenT_Permutation (APIO22_perm)C++17
10 / 100
1089 ms3192 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 ; int dp[maxn] ; vector<int> construct_permutation(ll k){ k -- ; vector <int> ans ; int c= 0 ; while(k){ int 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...