区间DP

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; char s[];
int dp[][]; int main()
{
int i,j,k;
while(~scanf(" %s",s))
{
if(strcmp(s,"end")==) break;
int len=strlen(s);
for(i=len-; i>=; i--) s[i+]=s[i];
memset(dp,,sizeof(dp)); for(i=; i<=len; i++) //长度
{
for(j=; j<=len; j++) //起点
{
int w=i+j-;//终点
if(w<=j||w>len) continue;
if((s[j]=='('&&s[w]==')')||(s[j]=='['&&s[w]==']'))
dp[j][w]=dp[j+][w-]+;
for(k=j; k<w; k++)
dp[j][w]=max(dp[j][w],dp[j][k]+dp[k+][w]);
}
}
printf("%d\n",dp[][len]);
}
return ;
}

SCU 1069 POJ 2955 Brackets的更多相关文章

  1. poj 2955 Brackets dp简单题

    //poj 2955 //sep9 #include <iostream> using namespace std; char s[128]; int dp[128][128]; int ...

  2. poj 2955 Brackets

    题目链接:http://poj.org/problem?id=2955 思路:括号匹配问题,求出所给序列中最长的可以匹配的长度(中间可以存在不匹配的)例如[(])]有[()]符合条件,长度为4 dp[ ...

  3. POJ 2955 Brackets(括号匹配一)

    题目链接:http://poj.org/problem?id=2955 题目大意:给你一串字符串,求最大的括号匹配数. 解题思路: 设dp[i][j]是[i,j]的最大括号匹配对数. 则得到状态转移方 ...

  4. poj 2955 Brackets (区间dp 括号匹配)

    Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...

  5. HOJ 1936&POJ 2955 Brackets(区间DP)

    Brackets My Tags (Edit) Source : Stanford ACM Programming Contest 2004 Time limit : 1 sec Memory lim ...

  6. Poj 2955 brackets(区间dp)

    Brackets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7795   Accepted: 4136 Descript ...

  7. POJ - 2955 Brackets括号匹配(区间dp)

    Brackets We give the following inductive definition of a “regular brackets” sequence: the empty sequ ...

  8. poj 2955 Brackets (区间dp基础题)

    We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a ...

  9. POJ 2955 Brackets (区间dp入门)

    Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...

随机推荐

  1. 使用inno setup制作安装包

  2. C#模板打印功能-模板为WPS或Excel

    //---WPS----- using EtApp = ET; using System.Reflection; using System.Runtime.InteropServices; using ...

  3. Flexslider图片轮播、文字图片相结合滑动切换效果

    Flexslider是一款基于的jQuery内容滚动插件.它能让你轻松的创建内容滚动的效果,具有非常高的可定制性.开发者可以使用Flexslider轻松创建各种图片轮播效果.焦点图效果.图文混排滚动效 ...

  4. 获取控件id

    普通状态中JS获取控件IDdocument.getElementById('controlID'); JS获取父窗口控件IDwindow.parent.document.getElementById( ...

  5. Webdriver其他定位方式

    1.下拉框的定位 在遇到select下拉框的选择时,比如: <select id="nr" name="NR"> <option select ...

  6. 12C RMAN 备份参考

    12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考 1.cdb启动和pdb关系测试 [oracle@xifenfei tmp]$ s ...

  7. [转]URL的解析,C语言实现

    http://blog.csdn.net/cuishumao/article/details/10284463 一 说明(1)应用情况:比如基于socket来实现http协议等,这时候就需要解析URL ...

  8. Hibernate5-课程笔记2

    单表的增删改查操作: (1)定义获取Session和SessionFactory的工具类: package com.tongji.utils; import org.hibernate.Session ...

  9. JAVA: 接入YSDK遇到的问题

    JAVA后台接口: 1, 腾讯开放平台: http://wiki.open.qq.com/wiki/%E9%A6%96%E9%A1%B5 2,YSDK介绍,大概流程: http://wiki.open ...

  10. PAT 团体程序设计天梯赛-练习集L1-011. A-B

    本题要求你计算A-B.不过麻烦的是,A和B都是字符串 —— 即从字符串A中把字符串B所包含的字符全删掉,剩下的字符组成的就是字符串A-B. 输入格式: 输入在2行中先后给出字符串A和B.两字符串的长度 ...