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. 一款不错的jQuery分页插件--pagination

    一.前言: 分页功能在项目中时常用到,一款可以快速实现分页功能的插件非常有必要,pagination--这款插件功能非常完美,几乎我所有项目中使用到分页的地方都会第一时间考虑到这个插件,但是其实有能力 ...

  2. chrome cpu占用100%

    参考原文地址:https://stackoverflow.com/questions/20276097/chrome-devtools-100-cpu 问题描述,chrome打开devtools开发者 ...

  3. WPF捕获全局未处理异常

    在WPF开发过程中我们一般都用try/catch块来捕获异常,但不是每个异常我们都能捕获,程序总会出现一些意想不到情况,抛出一些未捕获的异常,这时就要用到全局异常捕获,即在程序的最外层加上捕获未处理异 ...

  4. thinkphp3.2----实现伪静态和路由配置

    URL模式: 0.普通   http://localhost/qixin/ThinkCMF(test)_backup/index.php?g=user&m=login&a=index ...

  5. Machine learning吴恩达第三周 Logistic Regression

    1. Sigmoid function function g = sigmoid(z) %SIGMOID Compute sigmoid function % g = SIGMOID(z) compu ...

  6. Kettle根据表输入的SQL脚本返回创建表的SQL脚本

    其中[物料分组]节点就是表输入,里面可以构建SQL查询.那么怎么把生成的数据插入到目标表中?并且构建目标表的结构呢? 目标表结构就在[表输出]栏位 点击[SQL],就可以看见生成目标表结构的脚本

  7. POJ_2155 Matrix 【二维树状数组】

    一.题面 POJ2155 二.分析 楼教主出的题,是二维树状数组非常好的题,还结合了开关问题(开关变化的次数如果为偶数,状态不变,奇数状态相反). 题意就是给了一个二维的坐标平面,每个点初始值都是0, ...

  8. 使用docker部署STF服务(CentOS环境)

    一.安装docker环境 更新软件 sudo yum update 执行安装 sudo yum install docker 查看docker镜像 sudo docker images 二.拉取相关镜 ...

  9. python学习14-模块

    引入模块的方式: 1. import 模块 2. from xxx import 模块 一.collections 模块 1.Counter() counter是一个计数器,主要用来计数,计算一个字符 ...

  10. pandas数据清洗

    1.我已安装好Anavonda3.5.所以我只用打开"jupyter notebook",然后打开浏览器 然后点击右侧的“new",然后打开python3