//poj 2955
//sep9
#include <iostream>
using namespace std;
char s[128];
int dp[128][128];
int n; int rec(int l,int r)
{
if(dp[l][r]!=-1)
return dp[l][r];
if(l==r)
return dp[l][r]=0;
if(l+1==r){
if(s[l]=='('&&s[r]==')')
return dp[l][r]=2;
if(s[l]=='['&&s[r]==']')
return dp[l][r]=2;
}
int maxx=0;
if(s[l]=='('&&s[r]==')')
maxx=max(maxx,2+rec(l+1,r-1));
if(s[l]=='['&&s[r]==']')
maxx=max(maxx,2+rec(l+1,r-1));
for(int k=l;k<=r-1;++k)
maxx=max(maxx,rec(l,k)+rec(k+1,r));
return dp[l][r]=maxx;
} int main()
{
while(scanf("%s",s)==1){
if(s[0]=='e')
break;
memset(dp,-1,sizeof(dp));
n=strlen(s);
printf("%d\n",rec(0,n-1));
}
return 0;
}

最新文章

  1. Python-模块的使用
  2. MS AX 技术相关网站收藏
  3. treeview_dropdown_control
  4. 重叠(Overlapping) NAT
  5. JQuery 预热
  6. node 搭建开发框架express
  7. TreeSet()详解
  8. 爬虫框架Scrapy
  9. 关于SVM数学细节逻辑的个人理解(三) :SMO算法理解
  10. 在Winform开发框架中对附件文件进行集中归档处理
  11. spring中classpath
  12. IntelliJ IDEA 中创建maven项目
  13. UVALive 4725 Airport(二分)
  14. spring cloud配置中心属性加密处理
  15. tomcat如何在server.xml中配置contexts
  16. getParameter和getAttribute区别
  17. The serializable class XXX does not declare a static final serialVersionUID field of type long
  18. 二路归并排序java实现
  19. oracle判断查询结果是否为空
  20. MyBitis(iBitis)系列随笔之三:简单实现CRUD

热门文章

  1. java 8 stream使用
  2. python学习笔记(2)——练习小程序之 &quot; input &quot; 隐藏陷阱
  3. HDU_1203_01背包
  4. 04Servlet的生命周期
  5. elk大纲
  6. UVA - 10410 Tree Reconstruction(栈处理递归)
  7. session--保持登录20分钟,常用与用户登录状态
  8. 如何使用微信小程序video组件播放视频
  9. 3. Python中的分支判断、循环
  10. java增强for循环中获取index