Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
DP居然能超时!! 。。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator