| Codeforces Round 1137 (Div. 2) |
|---|
| Contest is running |
| 00:46:28 |
| Score | |
|---|---|
| Problem A | 354 |
| Problem B | 531 |
| Problem C | 885 |
| Problem D | 1416 |
| Problem E | 1416 |
| Problem F | 1770 |
| Successful hack | 100 |
| Unsuccessful hack | -50 |
| Unsuccessful submission | -50 |
| Resubmission | -50 |
You are given an array of integers $$$a_1, a_2, \ldots, a_n$$$ and an integer $$$k$$$.
Find the number of integers $$$1 \le i \le k$$$ such that in all subsequences$$$^{\text{∗}}$$$ of the array $$$a$$$ of length $$$k$$$, the same number is located at the $$$i$$$-th position.
$$$^{\text{∗}}$$$A sequence $$$b$$$ is a subsequence of a sequence $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by the deletion of several (possibly, zero or all) element from arbitrary positions.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$).
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output one integer — the number of positions at which the same number is located in all subsequences of length $$$k$$$ of the array $$$a$$$.
71 113 12 2 34 21 1 1 14 21 2 1 24 44 1 4 25 31 2 2 2 56 51 1 2 2 1 1
1020413
In the first test case, the array $$$a$$$ has exactly one subsequence of length $$$1$$$, so the answer is one.
In the second test case, the array $$$a$$$ has three subsequences of length $$$1$$$: $$$[a_1]$$$, $$$[a_2]$$$, and $$$[a_3]$$$. The answer is zero, because at the first position there can be either the number $$$2$$$ or the number $$$3$$$.
In the third test case, all subsequences of length $$$2$$$ of the array $$$a$$$ are equal to $$$[1, 1]$$$, so the answer is two.
In the fourth test case, the array $$$a$$$ has six subsequences of length $$$2$$$. It is enough to consider two of them: $$$[a_1, a_4] = [1, 2]$$$ and $$$[a_2, a_3] = [2, 1]$$$. The answer for this test case is zero, because at both positions there can be either one or two.
In the fifth test case, the array $$$a$$$ has exactly one subsequence of length $$$4$$$, so the answer is four.
| Name |
|---|


