病毒 LCIS
来源:互联网 发布:ug汽车大模具编程刀路 编辑:程序博客网 时间:2024/05/17 03:52
你有一个日志文件,里面记录着各种系统事件的详细信息。自然的,事件的时间戳按照严格递增顺序排列(不会有两个事件在完全相同的时刻发生)。
遗憾的是,你的系统被病毒感染了,日志文件中混入了病毒生成的随机伪事件(但真实事件的相对顺序保持不变)。备份的日志文件也被感染了,但由于病毒采用的随机感染方法,主日志文件和备份日志文件在感染后可能会变得不一样。
给出被感染的主日志和备份日志,求真实事件序列的最长可能长度。
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 <string>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <algorithm>#include <queue>#include <map>#include <vector>#define MM(s,q) memset(s,q,sizeof(s))#define INF 0x3f3f3f3f#define MAXN 1005#define Lchild id<<1#define Rchild (id<<1)+1using namespace std;int a[MAXN], b[MAXN], dp[MAXN];int LCIS(int x, int y) { MM(dp, 0); for (int i = 0; i < x; i++) { int Max = 0; for (int j = 0; j < y; j++) { if (a[i] > b[j] && dp[j] > Max) Max = dp[j]; if (a[i] == b[j]) dp[j] = Max + 1; } } int ans = 0; for (int i = 0; i < y; i++) ans = max(ans, dp[i]); return ans;}int main() { int T, n, x, y; cin >> T; while (T--) { cin >> x; for (int i = 0; i < x; i++) scanf("%d", &a[i]); cin >> y; for (int i = 0; i < y; i++) scanf("%d", &b[i]); cout << LCIS(x, y) << endl; }}
0 0
- 病毒 LCIS
- CSU 1120 病毒(LCIS)
- csu 1120 病毒(DP,LCIS)
- CSU 1120 病毒 最长公共上升子序列(LCIS)
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- LCIS
- CDOJ1300 LCIS
- hdu4512 LCIS
- 如何控制android中ImageView的位置
- python 将对象设置为可迭代有两种实现方式
- Google数据分析
- 小白训练Day3
- 私人笔记
- 病毒 LCIS
- .NET 线程对象私有字段侵入式编程
- java如何生成二维码
- 【阅读】 软技能——代码之外的生存指南
- NSOJ 国王的魔镜
- mysql
- python 命令行参数
- Live555中RTP包的打包与发送过程分析2
- eclipse 控制台乱码