Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

DP居然能超时!! 。。。。

Posted by bool at 2006-02-13 15:16:12 on Problem 1458
#include <iostream>
using namespace std;
int main()
{
    char a[100],b[100];
    int i,j;
    while(cin>>a>>b)
    {
       int n=strlen(a),m=strlen(b),l[100][100]={0};
       for(i=0;i<n;i++)
           for(j=0;j<m;j++)
           {
              if (a[i]==b[j])
                   l[i+1][j+1]=l[i][j]+1;
              else  if(l[i][j+1]>l[i+1][j])
                       l[i+1][j+1]=l[i][j+1];
                    else  l[i+1][j+1]=l[i+1][j];
           }  
        cout<<l[n][m]<<endl;           
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator