C1736 [CEOI2018Day1] Lottery

内存限制:32 MB 时间限制:1000 ms

题目描述

For a long long time you have been a big fan of Bytelotto. For around the same time, the members of your family have been telling you that all such games are a waste of money. You are sure that it is because of their lack of skill! You have a brilliant plan and everyone will see you winning the game soon.

There are many types of games. You are interested in one of them: Bitlotto. The choice was simple, as it is the easiest offered type of game: on each day exactly one number is drawn at random. You took notes the results of draws in $n$ consecutive days and obtained a sequence $a_1,a_2,...,a_n$. You are sure that there is some pattern in this sequence, especially in intervals of $l$ consecutive days. Your family still does not believe you, so the only way to convince them is to use solid math.

There are $n−l+1$ intervals of days of length $l$. The $i$-th interval starts at position $i$, so it contains elements $a_i,a_{i+1},...,a_{i+l−1}$. The distance between two intervals is the number of mismatches on their corresponding positions. In other words, for the $x$-th and the $y$-th interval it is the number of positions $i (0 ≤ i < l)$ such that $a_{x+i}$ and $a_{y+i}$ are different. Finally, we define two intervals to be $k$-similar if their distance is at most $k$.

There is a fixed sequence and an integer $l$. You are given $q$ queries. In every query, you are given an integer $k_j$ and for each of the $n − l + 1$ intervals you must find the number of intervals of the same length that are $k_j$-similar to this interval (not counting this interval itself).

输入格式

The first line of the standard input contains two space-separated integers $n$ and $l (1 ≤ l ≤ n ≤ 10000)$, the number of days and the length of the analysed intervals. The second line contains $n$ space-separated integers $a_1,a_2,...,a_n (1 ≤ a_i ≤ 10^9)$, where $a_i$ is the number that was drawn on the $i$-th day.

The third line contains an integer $q (1 ≤ q ≤ 100)$, the number of queries. Each of the next $q$ lines contains an integer $k_j (0 ≤ k_j ≤ l)$, the similarity parameter for the $j$-th query.

输出

Print $q$ lines. The $j$-th line should contain $n − l + 1$ space-separated integers that are the answer to the $j$-th query. The $i$-th number in a line should be the number of other intervals that are $k_j$-similar to the $i$-th interval.

样例

样例输入 1

6 2 1 2 1 3 2 1 2 1 2

样例输出 1

2 1 1 1 1 4 4 4 4 4

提示

Grading

The test set is divided into the following subtasks with additional constraints. Tests in each of the subtasks consist of one or more separate test groups. Each test group may contain one or more test cases.

image.png