问题 21813 --See LCS again

21813: See LCS again

时间限制: 1 Sec  内存限制: 64 MB
提交: 28  解决: 11
[提交][状态][讨论版][数据上传:][下载FPS1元][下载测试数据1元][752kb]

题目描述

There are A, B two sequences, the number of elements in the sequence is n、m;

Each element in the sequence are different and less than 100000.

Calculate the length of the longest common subsequence of A and B.

输入

The input has multicases.Each test case consists of three lines;
The first line consist two integers n, m (1 < = n, m < = 100000);
The second line with n integers, expressed sequence A;
The third line with m integers, expressed sequence B;

输出

For each set of test cases, output the length of the longest common subsequence of A and B, in a single line.

样例输入

5 4
1 2 6 5 4
1 3 5 4

样例输出

3

提示

来源

[提交][状态]