\[\begin{aligned} &f_{i, j, k}, g_{i, j, k} \to (i \text{ permutation}, j \text{ premax or sufmax},k (a[l] > a[l - 1])) \\ &\text{Initialize : } f_{1,1,0}=g_{1,1,0}=1\\ &\text{Transfer for f,g}\\ &f_{i,j,k} = f_{i-1,j-1,k-1}+f_{i-1,j,k}\times(k+1)+f_{i-1,j,k-1}\times (i-k-1)\\ &g_{i,j,k} = g_{i-1,j-1,k}+g_{i-1,j,k}\times k+g_{i-1,j,k-1}\times (i-k)\\ &\text{Now you know f, g, a, b and c}\\ &n= \texttt{forall interger} \in [1,N],C_{N-1}^{n-1}\times \sum^n_{i = 1,} \sum^{i-1}_{j=0 \text{ for premax,}} \sum^{n-i}_{k=0\text{ for sufmax,}} \sum^{i-2}_{l=0 \text{ for }f_k,} \sum^{n-i-1}_{m=0 \text{ for } g_k}f_{i-1,j,l} \times g_{n-i,k,m} \times a_{j+1} \times b_{k+1} \times {c_{l+m+[i\not=1]}} \to \text{ans}_n\\ &\text{Try to find ans of } \mathcal{O}(N^3)\\ &\text{Define }F_{i,k}=\sum ^{n}_{j=0} f_{i,j,k}\times a_{j+1},G_{i,k}=\sum ^{n}_{j=0} g_{i,j,k}\times b_{j+1}\\ &\text{ans}_n=C_{N-1}^{n-1}\times\sum^n_{i=1,}\sum^{i-2}_{l=0 \text{ for }f_k,} \sum^{n-i-1}_{m=0 \text{ for } g_k} F_{i-1,l} \times G_{n-i,m}\times {c_{l+m+[i\not=1]}}\\ &\text{Define } H_{i,m}=\sum^{i-1}_{l=0} F_{i,l}\times c_{m+l+[i\not=0]}\\ &\text{ans}_n=C_{N-1}^{n-1}\times\sum^{n}_{i=1} \sum^{n-i-1}_{m=0 \text{ for } g_k} G_{n-i,m}\times H_{i-1,m} \end{aligned} \] 标签:较草,题解,sum,ans,CF1988F,times,text From: https://www.cnblogs.com/SFsaltyfish/p/18325584