当前位置:网站首页>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;
}
边栏推荐
- QT foreach keyword
- Tree drop-down selection box El select combined with El tree effect demo (sorting)
- Labor skills courses integrated into steam Education
- In vscade, how to use eslint to lint and format
- Share 10 interview questions related to JS promise
- VerilogA - counter
- 目标检测——使用yolov6进行视频推理
- . NETCORE uses redis to limit the number of interface accesses
- About DDNS
- Effective methods for construction enterprises to select smart construction sites
猜你喜欢

What are the conditions for a high-quality public chain?

As a qualified network worker, you must master DHCP snooping knowledge!

RPC and RMI

Ci tool Jenkins II: build a simple CI project

数据库-同义词

The realization of changing pop-up background at any time

Solve the problem that NPM does not have permission

And check the collection hello

json tobean

【OSPF引入直连路由时巧借静态黑洞路由做汇总】
随机推荐
Message queue avoiding repeated refund by idempotent design and atomic lock
树形下拉选择框el-select结合el-tree效果demo(整理)
How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli
Qt 自定义位操作类
Mongostat performance analysis
VerilogA - dynamic comparator
[translation] [Chapter 2 ③] mindshare PCI Express technology 3.0
Qt 处理图像数据的类区别(QPixmap、QImage、QPicture)
[C language] flexible array
jetson tx2
It is the only one in China that Alibaba cloud container service has entered the Forrester leader quadrant
消息队列之通过幂等设计和原子锁避免重复退款
Introduction to NoSQL database
Message queue batch processing refund order through queue
QT qframe details
JDBC连接数据库,socket发送客户端。
关于DDNS
What are the conditions for a high-quality public chain?
NoSQL数据库之Redis(四):Redis的发布和订阅
Better than postman! Apipost knows more about Chinese programmers! How delicious!