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

HELP!! 为啥说 runtime error 啊?(1458)自己运行时通过了的。。。郁闷

Posted by Skipper at 2008-03-02 21:15:07 on Problem 1458
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int _length[2][100];
struct Length
{
	int* operator [](int i)
	{
		return _length[i%2];
	}
} length;


int judge(string A, string B)
{
	int m = A.size();
	int n = B.size();

	for (int i = 0; i <= m; i++)
		for (int j = 0; j <= n ;j++)
		{
			if (i == 0 || j == 0)
				length[i][j] = 0;
			else if (A[i-1] == B[j-1])
			{
				length[i][j] = length[i-1][j-1] + 1;
			}
			else
			{
				if (length[i-1][j] <= length[i][j-1])
					length[i][j] = length[i][j-1];
				else
					length[i][j] = length[i-1][j];
			}
		}

	return length[m][n];
}


int main()
{
	string A, B;
	
	while (cin >> A, cin >> B)
	{
		
		cout << judge(A, B) << 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