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

很多人问,贴一个0ms精简18行代码。

Posted by uaifeng at 2018-02-15 11:41:28 on Problem 1458
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
	string s1, s2;
	while(cin >> s1 >> s2){
		vector<vector<int> > c(s1.size() + 1, vector<int> (s2.size() + 1, 0));
		for(int i = 1; i <= s1.size(); ++i)
			for(int j = 1; j <= s2.size(); ++j)
				if(s1[i - 1] == s2[j - 1])
					c[i][j] = c[i - 1][j - 1] + 1;
				else
					c[i][j] = max(c[i - 1][j], c[i][j - 1]);
		cout << c[s1.size()][s2.size()] << 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