「NnOI R2-T4」Colorful Days♪

Luogu
IDLGP9572
Time1000ms
Memory512MB
DifficultyP3
二分洛谷原创O2优化
给出如下定义: 1. 定义 $ AB $ 为 $ A $ 数组后拼接 $ B $ 数组。 2. 定义 $ A^{0}=\{\} $(即空数组),且对 $i=1,2,3,\cdots$,$ A^{i}=A^{i-1}A$。 2. 定义 $ \operatorname{LCS}(A,B) $ 为 $ A $ 数组和 $ B $ 数组的**最长公共子序列**长度。 现给定长度为 $ n $ 的数组 $ S $ 和长度为 $ m $ 的数组 $ T $,数组中的数均为正整数。 你现在需要找到最小的非负整数 $k$,使得 $ \operatorname{LCS}(S^k,T) $ 最大。 出题人很仁慈,如果你无法最小化 $k$,你也可以拿到一部分分数。 ## Input 第一行四个整数 $ n,m,c_1,c_2 $,后两个整数为输出参数 0 或 1。 第二行 $ n $ 个正整数,代表 $ S $ 数组。 第三行 $ m $ 个正整数,代表 $ T $ 数组。 ## Output 输出两个整数 $ c_1 \cdot \operatorname{LCS}(S^k,T)$ 和 $c_2\cdot k$。 [samples] ## Note **【样例 1 解释】** 当 $k = 2$ 时,$S^k = \text{\{23 34 \textcolor{red}{53 23 34} 53\}}$,其中标红的是 $S^k$ 和 $T$ 的最长公共子序列。 **【数据范围】** **提示:本题开启捆绑测试。** 对于 $ 100\% $ 的数据,保证 $ 1 \le n,m,S_i,T_i \le 10^6 $,$ c_1,c_2 \in \{0,1\} $。 $$ \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} $$ 在赛后新添加的 hack 测试点会加入 subtask7。 ### 题目来源 | 项目 | 人员 | |:-:|:-:| |idea| 船酱魔王 | |data| 船酱魔王 | |check| Sudohry | |solution| 船酱魔王 |
Samples
Input #1
3 4 1 1
23 34 53
53 25 23 34
Output #1
3 2
Input #2
9 10 1 1
15 12 26 21 26 21 23 12 23
26 11 21 15 16 15 12 23 17 12
Output #2
7 3
API Response (JSON)
{
  "problem": {
    "name": "「NnOI R2-T4」Colorful Days♪",
    "description": {
      "content": "给出如下定义: 1. 定义 $ AB $ 为 $ A $ 数组后拼接 $ B $ 数组。 2. 定义 $ A^{0}=\\{\\} $(即空数组),且对 $i=1,2,3,\\cdots$,$ A^{i}=A^{i-1}A$。 2. 定义 $ \\operatorname{LCS}(A,B) $ 为 $ A $ 数组和 $ B $ 数组的**最长公共子序列**长度。 现给定长度为 $ n $ 的数组 ",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9572"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给出如下定义:\n\n1. 定义 $ AB $ 为 $ A $ 数组后拼接 $ B $ 数组。\n2. 定义 $ A^{0}=\\{\\} $(即空数组),且对 $i=1,2,3,\\cdots$,$ A^{i}=A^{i-1}A$。\n2. 定义 $ \\operatorname{LCS}(A,B) $ 为 $ A $ 数组和 $ B $ 数组的**最长公共子序列**长度。\n\n现给定长度为 $ n $ 的数组 ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments