Input
输入第一行为数据组数T (T<=100)。每组数据包含两行,分别描述感染后的主日志和备份日志。每个日志文件的格式相同,均为一个整数n (1<=n<=1000)(代表感染后的事件总数)和n 个不超过100,000的正整数(表示感染后各事件的时间戳)。注意,感染后可能会出现时间戳完全相同的事件。Output
对于每组数据,输出真实事件序列的最长可能长度。
Sample Input
1
9 1 4 2 6 3 8 5 9 1
6 2 7 6 3 5 1
Sample Output
3
---------------------------------我是分割线^_^---------------------------------------
模板~~~日后慢慢理解........= =
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define Int __int64
#define pii pair<int,int>
const int MAXN = 1111;
int num1[MAXN];
int num2[MAXN];
int dp[MAXN];
int main() {
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w+", stdout);
int cas;
while (cin >> cas) {
while (cas--) {
memset(dp, 0, sizeof(dp));
int n1, n2;
cin >> n1;
for (int i = 1; i <= n1; i++) {
cin >> num1[i];
}
cin >> n2;
for (int i = 1; i <= n2; ++i) {
cin >> num2[i];
}
int Max = 0;
for (int i = 1; i <= n1; i++) {
Max = 0;
for (int j = 1; j <= n2; j++) {
if (num1[i] > num2[j] && Max < dp[j]) {
Max = dp[j];
}
if (num1[i] == num2[j]) {
dp[j] = Max + 1;
}
}
}
Max = 0;
for (int i = 1; i <= n2; i++) {
if (dp[i] > Max) {
Max = dp[i];
}
}
cout << Max << endl;
}
}
return 0;
}