#A. 【模板】最长公共子序列

    Type: RemoteJudge 1000ms 125MiB

【模板】最长公共子序列

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给出 1,2,,n1,2,\ldots,n 的两个排列 P1P_1P2P_2 ,求它们的最长公共子序列。

输入格式

第一行是一个数 nn

接下来两行,每行为 nn 个数,为自然数 1,2,,n1,2,\ldots,n 的一个排列。

输出格式

一个数,即最长公共子序列的长度。

5 
3 2 1 4 5
1 2 3 4 5

3

提示

  • 对于 50%50\% 的数据, n103n \le 10^3
  • 对于 100%100\% 的数据, n105n \le 10^5

天河c线性dp时空优化

Not Attended
Status
Done
Rule
IOI
Problem
3
Start at
2025-3-30 18:57
End at
2025-3-30 21:27
Duration
2.5 hour(s)
Host
Partic.
12