#P9572. 「NnOI R2-T4」Colorful Days♪
「NnOI R2-T4」Colorful Days♪
Problem Description
The following definitions are given:
- Define as the array obtained by concatenating array followed by array .
- Define (i.e., the empty array). For , define .
- Define as the length of the Longest Common Subsequence of arrays and .
Now you are given an array of length and an array of length . All numbers in the arrays are positive integers.
You need to find the smallest non-negative integer such that is maximized.
The problem setter is very kind: if you cannot minimize , you can still get partial points.
Input Format
The first line contains four integers . The last two integers are output parameters, either or .
The second line contains positive integers, representing array .
The third line contains positive integers, representing array .
Output Format
Output two integers and .
3 4 1 1
23 34 53
53 25 23 34
3 2
9 10 1 1
15 12 26 21 26 21 23 12 23
26 11 21 15 16 15 12 23 17 12
7 3
Hint
[Sample 1 Explanation]
When , $S^k = \text{\{23 34 \textcolor{red}{53 23 34} 53\}}$, where the red part is a longest common subsequence of and .
[Constraints]
Note: This problem uses bundled testdata.
For of the testdata, it is guaranteed that , and .
$$\def\r{\cr\hline} \def\None{\text{None}} \def\arraystretch{1.5} \begin{array}{c|c|c} \textbf{Subtask} & \textbf{Sp. Constraints} & \textbf{Score}\r \textsf1& c_1=c_2=0 & 2 \r \textsf2& n \le 10^3,m \le 10^2 & 8 \r \textsf3& n \le 10^4,m \le 10^3 & 15 \r \textsf4& c_2=0 & 15 \r \textsf5& n,m \le 10^5,S_i,T_i \le 26 & 20 \r \textsf6& 无特殊限制 & 40 \r \end{array}$$The newly added hack test points after the contest will be included in subtask 7.
Problem Source
| Item | Person |
|---|---|
| idea | Chuanjiang Mowang |
| data | |
| check | Sudohry |
| solution | Chuanjiang Mowang |
Translated by ChatGPT 5