POJ 2955 Brackets
来源:互联网 发布:晃然学姐的淘宝店 编辑:程序博客网 时间:2024/05/16 10:54
POJ 2955 Brackets
#include <iostream>#include <algorithm>#include <cstdio>#include <string.h>#include <string>using namespace std;//dp[i][i+j] = max{dp[i][k]+dp[k+1][i+j], dp[i-1][i+j-1]+(s[i]<->s[i+j]是否匹配)} | k:i...i+j-1;string s1;int dp[105][105];int main(){// freopen("1.txt","r",stdin); while(cin>>s1,s1[0]!='e') { memset(dp,0,sizeof(dp)); int len=s1.length(); for (int i = len-1; i >= 0; --i) //倒过来 { for (int j = i+1; j < len; ++j) { if(s1[i]=='('&&s1[j]==')' || (s1[i]=='['&&s1[j]==']')) dp[i][j] = dp[i+1][j-1]+2; for (int k = i+1; k <= j; ++k) { dp[i][j]=max(dp[i][j],dp[i][k-1]+dp[k][j]); } } } cout<<dp[0][len-1]<<endl; } return 0;}
0 0
- DP poj 2955 Brackets
- poj 2955 brackets
- POJ 2955 Brackets
- POJ 2955 Brackets
- POJ 2955 Brackets
- poj 2955 Brackets
- POJ 2955 Brackets
- POJ 2955 Brackets
- poj 2955 Brackets
- POJ 2955 Brackets
- POJ 2955:Brackets
- POJ 2955 Brackets
- POJ 2955 brackets
- POJ 2955 Brackets
- POJ 2955 Brackets
- Brackets (poj 2955)
- poj 2955 Brackets
- POJ 2955 Brackets (基础)
- 跟着视频学Photoshop CC商业广告案例设计——互动出版网
- vector的一些操作
- H264 -3 NALU详解
- C# WinForm开发系列 - 文章索引
- postgre sql 类型转换
- POJ 2955 Brackets
- SpringMVC +Hibernate JPA+Spring-data-jpa
- 时间强奸犯
- 欢迎使用CSDN-markdown编辑器
- 计算IE的旋转角度与滤镜
- Genymation 此应用与您的手机不兼容
- 如何对ECShop的url路径进行优化
- PHP+Apache如何监控多个端口和配置多站点
- 我们为什么选择了Cassandra而没有用Hbase