第二个样例(输入第一行为 30 3 的那个)会让 std RE,当运行至 262626 行时,f[i - 1][q[hd]] - 1 为 −1-1−1,会触发数组越界.
30 3
f[i - 1][q[hd]] - 1