#P17139. [KOI 2026 #1] 跳跃
[KOI 2026 #1] 跳跃
Problem Description
There are platforms on a 2D coordinate plane, numbered from to . Each platform can be represented as a point on the plane. For each integer (), the coordinates of platform are .
For two integers (), you can move from platform to platform if and only if both of the following conditions are satisfied:
- .
- .
Here, is a given constant and is a positive integer.
Write a program that, for each platform, computes the number of distinct platforms that can be reached starting from that platform after making or more moves from one platform to another. Note that this number should include the starting platform itself.
Input Format
The first line contains two integers and , separated by spaces.
The second line contains integers , separated by spaces.
Output Format
Output integers on one line, separated by spaces. The -th integer represents the number of distinct platforms that can be reached starting from platform after making or more moves from one platform to another ().
6 2
3 5 4 6 1 3
6 4 3 1 2 1
6 3
1 4 8 9 10 15
2 1 3 2 1 1
3 2
1 4 7
1 1 1
Hint
Sample Explanation 1
For each platform, the platforms reachable from it are as follows:
- Platform : can reach all platforms, including platform itself.
- Platform : can reach platforms , , , and .
- Platform : can reach platforms , , and .
- Platform : cannot reach any other platform except platform itself.
- Platform : can reach platforms and .
- Platform : cannot reach any other platform except platform itself.
Constraints
- All numbers in the input are integers.
- .
- .
- For each integer (), .
Subtasks
- ( points) .
- ( points) .
- ( points) .
- ( points) For each integer (), .
- ( points) .
- ( points) No additional constraints.
Translator's note: There are no separate testdata points for subtask 5, so subtask 6 is worth points.
Translated by ChatGPT-5.6.
Translated by ChatGPT 5