http://blog.csdn.net/libin56842/article/details/9673239

http://www.cnblogs.com/ACMan/archive/2012/08/09/2630497.html

http://blog.csdn.net/chaiyuan414/article/details/5448699

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue const int MAXN = + ; int n,m; int dp[][];
char a[]; int main()
{
int i,j;
while(sf("%s",a)== && a[]!='e')
{
n = strlen(a);
mem(dp,);
for(int l = ;l<n;l++)
{
for(i=;i<n-l;i++)
{
j = i+l;
if((a[i]=='(' && a[j]== ')') || (a[i]=='[' && a[j]== ']'))
dp[i][j] = dp[i+][j-]+; for(int k =i+;k<j;k++)
{
dp[i][j] = max(dp[i][j],dp[i][k]+dp[k+][j]);
} }
}
pf("%d\n",dp[][n-]);
}
return ;
}

POJ 2955 Brackets 区间DP 最大括号匹配的更多相关文章

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

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

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

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

  3. poj 2955"Brackets"(区间DP)

    传送门 https://www.cnblogs.com/violet-acmer/p/9852294.html 题意: 给你一个只由 '(' , ')' , '[' , ']' 组成的字符串s[ ], ...

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

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

  5. POJ 2955 Brackets 区间DP 入门

    dp[i][j]代表i->j区间内最多的合法括号数 if(s[i]=='('&&s[j]==')'||s[i]=='['&&s[j]==']') dp[i][j] ...

  6. POJ 2955 Brackets(区间DP)

    题目链接 #include <iostream> #include <cstdio> #include <cstring> #include <vector& ...

  7. POJ 2995 Brackets 区间DP

    POJ 2995 Brackets 区间DP 题意 大意:给你一个字符串,询问这个字符串满足要求的有多少,()和[]都是一个匹配.需要注意的是这里的匹配规则. 解题思路 区间DP,开始自己没想到是区间 ...

  8. POJ2955--Brackets 区间DP入门 括号匹配

    题意很简单,就是求给出串中最大的括号匹配数目.基础题,格式基本为简单区间dp模板. #include<iostream> #include<string.h> using na ...

  9. A - Brackets POJ - 2955 (区间DP模板题)

    题目链接:https://cn.vjudge.net/contest/276243#problem/A 题目大意:给你一个字符串,让你求出字符串的最长匹配子串. 具体思路:三个for循环暴力,对于一个 ...

随机推荐

  1. python3之if与语句

    获得更多资料欢迎进入我的网站或者 csdn或者博客园 本节主要介绍python,if条件语句,以及用法.下面附有之前的文章: 语句快介绍 语句快并非一种语句,是通过缩进形成的语句集合: 可以使用的缩进 ...

  2. Win10通电自动开机的解决办法

    前几天Win10强推系统升级,更新后无意中发现每次通电电脑就自动开机了. 解决办法: 打开控制面板>电源选项>选择电源按钮的功能,把关机设置里的“启用快速启动(推荐)”选项去掉就可以了. ...

  3. 北航软院2012级C#期末考试部分考题解答

    博主注:本渣渣水平有限,文中若有不对的地方敬请指出,谢谢. 本文中大部分图片来自老师的PPT,感谢邵老师,想要的可以点击右边QQ联系我:) 一.选择题(2*15=30) 1.In C# what is ...

  4. 项目Alpha冲刺 6

    作业描述 课程: 软件工程1916|W(福州大学) 作业要求: 项目Alpha冲刺(团队) 团队名称: 火鸡堂 作业目标: 介绍第6天冲刺的项目进展.问题困难和心得体会 1.团队信息 队名:火鸡堂 队 ...

  5. linux内核修炼之道

    华清远见·任桥伟   人民邮电 2010 内核不学,岂能理解?今天开始正式学习内核原理 linux 发行版本Mint. cat  /etc/issue     # sudo lsb_release - ...

  6. [转] Java 命令行交互-JCommander

    [From] https://github.com/Sayi/sayi.github.com/issues/32 我喜欢简单,什么是简单?正如若干字符组成的命令行. 有时候我们用Java开发了一个小工 ...

  7. List<Type> 随机

    public List<T> GetRandomList<T>(List<T> inputList){ //Copy to a array T[] copyArra ...

  8. cookie session token详解

    cookie session token详解 转自:http://www.cnblogs.com/moyand/ 发展史 1.很久很久以前,Web 基本上就是文档的浏览而已, 既然是浏览,作为服务器, ...

  9. SD341X-SD343H蜗轮传动伸缩蝶阀厂家,SD341X-SD343H蜗轮传动伸缩蝶阀价格 - 专题栏目 - 无极资讯网

    无极资讯网 首页 最新资讯 最新图集 最新标签   搜索 SD341X-SD343H蜗轮传动伸缩蝶阀 无极资讯网精心为您挑选了(SD341X-SD343H蜗轮传动伸缩蝶阀)信息,其中包含了(SD341 ...

  10. es第三篇:Search APIs

    大多数search API都是可以操作多个索引的,除了explain API. 当执行一个search API时,可以指定routing参数,去搜索特定的主分片及其副本分片.routing参数值可以是 ...