当前位置:网站首页>uva10635
uva10635
2022-06-29 06:38:00 【小刀刺大熊】
//因为每个数都不同,可将A数组元素重新编号
//使得A数组为 1 - p+1 的数字
//删除B数组中 A没有的元素 求B数组的最长递增子序列长度 即为答案
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 250 * 250 + 7;
int idx[maxn], A[maxn], B[maxn], alen, blen, n;
int main()
{
int t;
cin >> t;
for (int kCase = 1; kCase <= t; kCase++) {
cin >> n >> alen >> blen;
memset(idx, 0, sizeof(idx));
int first = 1;
for (int i = 0; i <= alen; i++) {
cin >> A[i];
if (!idx[A[i]]) {
idx[A[i]] = first++;
}
}
int len = 0;
for (int i = 0; i <= blen; i++) {
cin >> B[len];
if (!idx[B[len]]) continue;
B[len] = idx[B[len]];
++len;
}
vector<int> dp = {
B[0] };
for (int i = 1; i < len; ++i) {
if (B[i] > dp.back()) {
dp.emplace_back(B[i]);
}
else {
auto it = lower_bound(dp.begin(), dp.end(), B[i]);
*it = B[i];
}
}
cout << "Case " << kCase << ": " << dp.size() << endl;
}
return 0;
}
边栏推荐
- NoSQL数据库之Redis(一):安装 & 简介
- Tree drop-down selection box El select combined with El tree effect demo (sorting)
- 大型化工企业数字化转型建议
- How to do the performance pressure test of "Health Code"
- Object detection - VIDEO reasoning using yolov6
- Service grid ASM year end summary: how do end users use the service grid?
- Instanceklass "suggestions collection" of hotspot class model
- Idea use
- 消息队列之通过队列批处理退款订单
- Domestic code hosting center code cloud
猜你喜欢
随机推荐
json tobean
And check the collection hello
The realization of changing pop-up background at any time
. NETCORE uses redis to limit the number of interface accesses
How does schedulerx help users solve distributed task scheduling problems?
JDBC connects to the database and socket sends the client.
Qt 容器类
Output of character pointer to string in C language
Vite快速上手
[translation] [Chapter 2 ②] mindshare PCI Express technology 3.0
Li Kou today's question -324 Swing sort II
QT serial port programming
Analytic hierarchy process
Qt 程序打包发布-windeployqt工具
Json对象和Json字符串的区别
Save token get token refresh token send header header
Qt 处理图像数据的类区别(QPixmap、QImage、QPicture)
作为一名合格的网工,你必须掌握的 DHCP Snooping 知识!
What are the conditions for a high-quality public chain?
Oscilloscope symbols









