P3205 [HNOI2010]合唱队
#include<bits/stdc++.h> using namespace std; const int n=1010; int h[n]; int N; int f[n][n][2]; int main(){ scanf("%d",&N); for(int i=1;i<=N;i++){ scanf("%d",&h[i]); } for(int i=1;i<=N;i++){ f[i][i][0]=1; } for(int l=1;l<=N;l++){ for(int i=1;i+l<=N;i++){ int j=i+l; if(h[i]<h[i+1])f[i][j][0]+=f[i+1][j][0]; if(h[i]<h[j])f[i][j][0]+=f[i+1][j][1]; if(h[j]>h[i])f[i][j][1]+=f[i][j-1][0]; if(h[j]>h[j-1])f[i][j][1]+=f[i][j-1][1]; f[i][j][0]%=19650827; f[i][j][1]%=19650827; } } printf("%d\n",(f[1][N][0]+f[1][N][1])%19650827); return 0; }
https://www.cnblogs.com/Liuz8848/p/11719556.html