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

以为递归要超时,结果居然水过去了

Posted by ohsohot at 2010-08-26 00:25:39 on Problem 3356
#include <iostream>
#include <string>
using namespace std;
string s1, s2;
int l1, l2;
int LCS(int x, int y)
{
	if (x >= l1 || y >= l2)
		return 0;
	if (s1[x] == s2[y])
		return 1+LCS(x+1, y+1);
	return max(LCS(x, y+1), LCS(x+1, y));
}
int main()
{
	while (cin>>l1)
	{
		cin>>s1>>l2>>s2;
		cout<<max(l1,l2)-LCS(0, 0)<<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