题面
Sol
简单(DP)
# include <bits/stdc++.h>
# define IL inline
# define RG register
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int _(1005);
const int Zsy(19650827);
IL ll Input(){
RG char c = getchar(); RG ll x = 0, z = 1;
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * z;
}
int n, a[_], f[2][_][_];
IL void Up(RG int &x, RG int y){
x += y;
if(x >= Zsy) x -= Zsy;
}
int main(RG int argc, RG char* argv[]){
n = Input();
for(RG int i = 1; i <= n; ++i) a[i] = Input(), f[0][i][i] = 1;
for(RG int i = 1; i < n; ++i)
for(RG int l = 1; l + i <= n; ++l){
RG int r = l + i;
if(a[l] < a[l + 1]) Up(f[0][l][r], f[0][l + 1][r]);
if(a[l] < a[r]) Up(f[0][l][r], f[1][l + 1][r]);
if(a[r - 1] < a[r]) Up(f[1][l][r], f[1][l][r - 1]);
if(a[l] < a[r]) Up(f[1][l][r], f[0][l][r - 1]);
}
printf("%d
", (f[0][1][n] + f[1][1][n]) % Zsy);
return 0;
}