Inaccurate Subsequence Search
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
题目描述
Maxim 有一个包含 个整数的数组 和一个包含 个整数的数组 (其中 )。
Maxim 认为长度为 的数组 是好的,如果 的元素可以通过重新排列,使得至少 个元素与数组 的元素相匹配。
例如,如果 且 ,那么数组 和 是好的(它们可以重新排列为 和 ),而数组 和 则不是好的。
Maxim 想要选择数组 中长度为 的每个子段作为数组 的元素。帮助Maxim计算有多少个选定的数组将是好的。
换句话说,找出位置 的数量,使得元素 形成一个好的数组。
输入格式
The first line contains an integer ( ) — the number of test cases.
The first line of each test case contains three integers , , and ( ) — the number of elements in arrays and , the required number of matching elements.
The second line of each test case contains integers ( ) — the elements of array . Elements of the array are not necessarily unique.
The third line of each test case contains integers ( ) — the elements of array . Elements of the array are not necessarily unique.
It is guaranteed that the sum of over all test cases does not exceed . Similarly, it is guaranteed that the sum of over all test cases does not exceed .
样例 #1
样例输入 #1
5
7 4 2
4 1 2 3 4 5 6
1 2 3 4
7 4 3
4 1 2 3 4 5 6
1 2 3 4
7 4 4
4 1 2 3 4 5 6
1 2 3 4
11 5 3
9 9 2 2 10 9 7 6 3 6 3
6 9 7 8 10
4 1 1
4 1 5 6
6
样例输出 #1
4
3
2
4
1