#P17134. [KOI 2026 #1] 邻居

    ID: 19477 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 显示难度入门 上传者: 标签>模拟枚举2026KOI(韩国)

[KOI 2026 #1] 邻居

Problem Description

In KOI Village, there is a straight road. There are a total of NN houses on the road. NN students numbered from 11 to NN live in these houses, with exactly one student in each house. For an integer ii (1iN1 \le i \le N), the coordinate of the house where student ii lives is ii. That is, the coordinate of student 11’s house is 11, and the coordinate of student NN’s house is NN.

There are two schools in KOI Village, called School 11 and School 22. Each student attends exactly one of these two schools.

For students ii and jj (iji \ne j), if at least one of the following conditions holds, then the two students are said to be neighbors of each other:

  • The two students attend the same school, and the distance between their houses is at most K1K_1.
  • The two students attend different schools, and the distance between their houses is at most K2K_2.

Here, the distance between two different houses is defined as the larger coordinate minus the smaller coordinate. For example, the distance between the house where student 33 lives and the house where student 55 lives is 53=25-3=2.

Write a program to compute, for each student, the number of students who are neighbors with them. Note that a student is not considered their own neighbor.

Input Format

The first line contains three integers NN, K1K_1, and K2K_2, separated by spaces.

The second line contains NN integers S1,S2,,SNS_1,S_2,\ldots,S_N, separated by spaces. Here, SiS_i is the index of the school that student ii attends (1iN1 \le i \le N).

Output Format

Output one line containing NN integers separated by spaces. The ii-th integer is the number of students who are neighbors with student ii (1iN1 \le i \le N).

5 1 2
1 1 1 2 2
1 3 3 3 2
5 1 1
1 1 1 2 2
1 2 2 2 1
7 3 1
1 1 1 1 1 1 1
3 4 5 6 5 4 3

Hint

Constraints

  • All numbers in the input are integers.
  • 2N30002 \le N \le 3\,000.
  • 1K1,K2N11 \le K_1,K_2 \le N-1.
  • For each integer ii (1iN1 \le i \le N), 1Si21 \le S_i \le 2.

Subtasks

Subtask Points Additional Constraints
11 55 N=2N=2
22 2525 K1=K2=1K_1=K_2=1
33 3535 S1=S2==SN=1S_1=S_2=\cdots=S_N=1
44 No additional constraints.

Translated by ChatGPT-5.6.

Translated by ChatGPT 5