简单的dp题..不能更水了..

---------------------------------------------------------------

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define clr(x,c) memset(x,c,sizeof(x))
using namespace std;
const int maxn=1000+5;
const int mod=19650827;
int n;
int goal[maxn];
int d[maxn][maxn][2];//0放入左,1放入右
int dp(int l,int r,int op) {
int &ans=d[l][r][op];
if(ans>=0) return ans;
ans=0;
if(op) {
if(goal[l]<goal[r]) ans=dp(l,r-1,0);
if(l!=r-1 && goal[r-1]<goal[r]) (ans+=dp(l,r-1,1))%=mod;
} else {
if(goal[l+1]>goal[l]) ans=dp(l+1,r,0);
if(l+1!=r && goal[r]>goal[l]) (ans+=dp(l+1,r,1))%=mod;
}
return ans%=mod;
}
int main()
{
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
clr(d,-1);
scanf("%d",&n);
rep(i,n) d[i][i][0]=d[i][i][1]=1;
rep(i,n) scanf("%d",&goal[i]);
printf("%d\n",(dp(0,n-1,0)+dp(0,n-1,1))%mod);
return 0;
}

---------------------------------------------------------------

1996: [Hnoi2010]chorus 合唱队

Time Limit: 4 Sec  Memory Limit: 64 MB
Submit: 1045  Solved: 672
[Submit][Status][Discuss]

Description

Input

Output

Sample Input

4
1701 1702 1703 1704

Sample Output

8

HINT

BZOJ 1996: [Hnoi2010]chorus 合唱队(dp)的更多相关文章

  1. BZOJ 1996: [Hnoi2010]chorus 合唱队(区间dp)

    题目: https://www.lydsy.com/JudgeOnline/problem.php?id=1996 题解: 这题刚拿到手的时候一脸懵逼qwq,经过思考与分析(看题解),发现是一道区间d ...

  2. bzoj 1996: [Hnoi2010]chorus 合唱队

    Description Input Output Sample Input 4 1701 1702 1703 1704 Sample Output 8 HINT Source 因为只会在区间的两端进行 ...

  3. 【BZOJ】1996: [Hnoi2010]chorus 合唱队【区间dp】

    1996: [Hnoi2010]chorus 合唱队 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 2088  Solved: 1371[Submit][ ...

  4. 1996: [Hnoi2010]chorus 合唱队 - BZOJ

    Description Input Output Sample Input41701 1702 1703 1704Sample Output8HINT 水题,区间dp,f[l,r,k]表示区间[l,r ...

  5. 1996: [Hnoi2010]chorus 合唱队

    链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1996 Description Input Output Sample Input 4 1701 ...

  6. BZOJ1996: [Hnoi2010]chorus 合唱队 (DP)

    就是想水一发 #include <stdio.h> #include <algorithm> #include <iostream> using namespace ...

  7. bzoj千题计划211:bzoj1996: [Hnoi2010]chorus 合唱队

    http://www.lydsy.com/JudgeOnline/problem.php?id=1996 f[i][j][0/1] 表示已经排出队形中的[i,j],最后一个插入的人在[i,j]的i或j ...

  8. bzoj1196:[Hnoi2010]chorus 合唱队

    这数据范围明显的区间dp啊...然而据说二维会wa...那就写三维把... #include<cstdio> #include<cstring> #include<cct ...

  9. 【BZOJ1996】[Hnoi2010]chorus 合唱队 区间DP

    [BZOJ1996][Hnoi2010]chorus 合唱队 Description Input Output Sample Input 4 1701 1702 1703 1704 Sample Ou ...

随机推荐

  1. 传智播客C/C++学院年薪24-50万招聘C/C++讲师

    C/C++技术讲师 6名 (北京,年薪:24-50万) 传智播客C/C++课程培训体系如下: 1.C语言,世界五百强C语言面试训练 2.C++语言,世界五百强C++语言面试训练 3.数据结构与算法,世 ...

  2. Vxlan 原理

    https://www.gitbook.com/book/yeasy/openstack_understand_neutron/details 自己总结一下: 分析 VTEP的情况, 即Vxlan跟V ...

  3. docker基于 aufs 文件系统

    docker的核心功能就是容器版本管理,在容器层实现了CVS版本管理,比如git那种可以commit/roll back 而AUFS就是其实现基础 AUFS可以实现文件系统的snapshot,这样对f ...

  4. 04737_C++程序设计_第6章_继承和派生

    例6.1 使用默认内联函数实现单一继承. #include<iostream> using namespace std; class Point { private: int x, y; ...

  5. XmlSerializer

    XmlSerializer作用是将对象序列化到 XML 文档中和从 XML 文档中反序列化对象.XmlSerializer 使您得以控制如何将对象编码到 XML 中. 所在的命名空间:System.X ...

  6. html基础标签-2-textarea文本域

    textarea文本域 <!doctype html> <html lang='zh-cn'> <head> <meta charset='utf-8'> ...

  7. JavaScript之面向对象学习五(JS原生引用类型Array、Object、String等等)的原型对象介绍

    1.原型模式的重要性不仅仅体现在创建自定义类型方面,就连所有的原生的引用类型(Obejct.Array.String等等)都在构造函数的原型上定义方法和属性.如下代码可以证明: alert(typeo ...

  8. ASP.NET动态生成图片样式的验证码

    我们在设计用户登录模块时,经常会用到验证码,可以有效地防止黑客软件的恶意破解. 在此我就直接放置一个网页链接,以后用的时候可以当做备忘! 此连接中有多种验证码图片的样式可供参考. http://www ...

  9. java 正则表达式抽取

    package com.achun.test; import java.util.regex.Matcher;import java.util.regex.Pattern; public class ...

  10. php采集文章中的图片获取替换到本地

    /** * 获取替换文章中的图片路径 * @param string $xstr 内容 * @param string $keyword 创建照片的文件名 * @param string $oriwe ...