就是想水一发
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <stdio.h> #include <algorithm> #include <iostream> using namespace std; typedef long long ll; const ll mod = 19650827; int q[1005]; ll dp[1005][1005][2]; int main() { int n; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &q[i]), dp[i][i][0] = 1; for(int len = 2; len <= n; len++) { for(int i = 1; i + len - 1 <= n; i++) { int j = i + len - 1; if(q[j] > q[j - 1]) dp[i][j][1] = (dp[i][j][1] + dp[i][j - 1][1]) % mod; if(q[j] > q[i]) dp[i][j][1] = (dp[i][j][1] + dp[i][j - 1][0]) % mod; if(q[i] < q[i + 1]) dp[i][j][0] = (dp[i][j][0] + dp[i + 1][j][0]) % mod; if(q[i] < q[j]) dp[i][j][0] = (dp[i][j][0] + dp[i + 1][j][1]) % mod; } } printf("%lld ", (dp[1][n][0] + dp[1][n][1]) % mod); return 0; }