#P17137. [KOI 2026 #1] 朋友
[KOI 2026 #1] 朋友
Problem Description
In KOI Village, there is a straight road. There are a total of houses on the road, and students numbered from to live in these houses, with exactly one student living in each house. For each integer (), the coordinate of the house where student lives is . No two houses are located at the same coordinate.
In addition, there are schools in KOI Village, numbered from to . For each integer (), student attends school .
For students and (), if at least one of the following conditions is satisfied, then these two students are considered friends of each other:
- The two students attend the same school, and the distance between their houses is at most .
- The two students attend different schools, and the distance between their houses is at most .
Here, the distance between two houses is defined as the absolute value of the difference of their coordinates. That is, the distance between the houses of student and student is .
Write a program to compute, for each student, the number of their friends. Note that a student is not considered a friend of themself.
Input Format
The first line contains three integers , , and , separated by spaces.
The next lines give the information of each student. In the -th of these lines, two integers and are given, separated by spaces ().
Output Format
Output integers on the first line, separated by spaces. The -th integer represents the number of friends of student ().
7 3 5
9 2
1 1
14 3
6 2
17 3
4 1
8 1
4 2 2 4 1 3 2
12 8 5
31 1
10 1
49 3
23 2
62 3
18 1
40 2
14 2
55 2
27 3
45 1
36 3
2 2 1 2 0 3 2 2 0 2 2 2
Hint
Constraints
- All numbers given in the input are integers.
- .
- .
- For each integer (), .
- For any integers (), .
- For each integer (), .
Subtasks
- ( points) .
- ( points) .
- ( points) For each integer (), and .
- ( points) .
- ( points) For each integer (), .
- ( points) No additional constraints.
Translated by ChatGPT-5.6.
Translated by ChatGPT 5