标签:out cin int end stream tar 分段 例题 eof main
#include <iostream>
#include <cstring>
using namespace std;
int dp[666][666];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string a;
while(cin>>a)
{
if(a[0]==‘e‘)
break;
memset(dp,0,sizeof(dp));
for(int i=1;i<=a.size();i++)
for(int j=0;j<a.size();j++)
{
int end=i+j-1;
if(end>a.size()-1)
continue;
if((a[j]==‘(‘&&a[end]==‘)‘)||(a[j]==‘[‘&&a[end]==‘]‘))
dp[j][end]=dp[j+1][end-1]+2;
for(int k=j;k<end;k++)
dp[j][end]=max(dp[j][end],dp[j][k]+dp[k+1][end]);
}
cout<<dp[0][a.size()-1]<<"\n";
}
}
标签:out cin int end stream tar 分段 例题 eof main
原文地址:https://www.cnblogs.com/baccano-acmer/p/10325022.html