Metal Steak

Hard to eat

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  0 Posts :: 79 Stories :: 0 Comments :: 0 Trackbacks

公告

aaaaaaaaaaaa

常用链接

留言簿(1)

我参与的团队

搜索

  •  

最新评论

#include <iostream>
using namespace std;

int
maxi, n, ans[
1001];
string str[1001];

bool
ifcontain( 
string str1, string str2 )
{
    
if( str2 == "*" )
        
return true;
    
if( str1.length() < str2.length() )
    {
        
for( unsigned int i = 0; i < str1.length(); i++ )
            
if( str1[i] != str2[i] )
                
return false;
        
return true;
    }
    
return false;
}

void
__read__()
{
    cin 
>> n;
    
forint i = 1; i <= n; i++ )
        cin 
>> str[i];
}

void
__init__()
{
    
forint i = 1; i <= n + 1; i++ )
        ans[i] 
= 1;
    str[n 
+ 1= "*";
}

void
__dp__()
{
    
forint i = 2; i <= n + 1; i++ )
        
forint j = 1; j < i; j++ )
            
if( ifcontain( str[j], str[i] ) )
                
if( ans[i] < ans[j] + 1 )
                    ans[i] 
= ans[j] + 1;
}

void
__outp__()
{
    cout 
<< ans[n + 1- 1 << endl;
}

int
main()
{
    __read__();
    __init__();
    __dp__();
    __outp__();

    
return 0;
}

posted on 2009-09-15 21:01 mad4alcohol 阅读(62) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理