#include <stdio.h> int main() { puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/43967361"); }
题解:
f[N][N][2]暴力维护即可。
代码:(水得我都不敢测样例就直接交了)
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 1005 #define inf 0x3f3f3f3f #define mod 19650827 using namespace std; int f[N][N][2]; int s[N],n; int main() { freopen("test.in","r",stdin); int i,j,k; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&s[i]),f[i][i][0]=1; for(j=1;j<n;j++)for(i=1;i+j<=n;i++) { f[i][i+j][0]=((s[i]<s[i+1])*f[i+1][i+j][0]+(s[i]<s[i+j])*f[i+1][i+j][1])%mod; f[i][i+j][1]=((s[i+j]>s[i])*f[i][i+j-1][0]+(s[i+j]>s[i+j-1])*f[i][i+j-1][1])%mod; } cout<<(f[1][n][0]+f[1][n][1])%mod<<endl; return 0; }
时间: 2024-10-10 23:52:40