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. linux下发邮件

    一. ubuntu中使用第三方mail 用qq地址有安全问题,可能是我的qq设置了安全限制,使用163邮箱可以 1. 安装个软件 apt-get install heirloom-mailx 2. 改 ...

  2. python全栈开发_day4_if,while和for

    一.if 1)if的用途 if常用于判断. 2)if的语法 tag=True tag2=True if tag: print("代码") elif tag2: print(&quo ...

  3. mysql里面 limit的奇效

    项目里面有遇到一个需求,查询一个表,先group by ,再按group 的count(*)进行倒序,取出每个group里面发表时间最新的一个纪录,之前的同事SQL是这样写的 SELECT * FRO ...

  4. Jenkins windows部署

    1.安装jenkins 进入https://jenkins.io/download/,下载windows安装包,解压后运行jenkins.msi进行安装. 配置jenkins (1)打开http:// ...

  5. 人机交互print

    python两种输出类型: 1· 表达式语句,python理解的 #  repr() 2· print() 结果是给用户看的      # str()  >>> "Hell ...

  6. Celery ValueError: not enough values to unpack (expected 3, got 0)的解决方案

    Celery ValueError: not enough values to unpack (expected 3, got 0)的解决方案 背景 最近因项目需要,学习任务队列Celery的用法,跟 ...

  7. 基于python实现Oracle数据库连接查询操作

    使用python语言连接Oracle数据库配置 #coding:utf-8 import cx_Oracle as oracle db=oracle.connect('root/123456@192. ...

  8. centos 7 下安装nginx-1.15.7

    安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境. 一. gcc 安装安装 nginx 需要先 ...

  9. 安装vs2013要求重启后安装

    解决方案: 卸载360,然后杀毒, 重启电脑就可以直接安装vs了

  10. UnxUtils让windows下的dos命令变为linux下的命令

    一.UnxUtils UnxUtils是一个可以支持在Windows下使用linux命令的工具,用习惯了linux之后,感觉Windows的dos命令实在是太难用了,发现了这个工具,非常的小,装了它之 ...