#P12008. 【MX-X10-T4】[LSOT-4] Fragment of Memories

    ID: 11649 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>倍增双指针 two-pointer梦熊比赛

【MX-X10-T4】[LSOT-4] Fragment of Memories

Description

Before falling into a coma, Susan experienced mm days of memories. Starting from the first day, Susan has a base memory value xx. The memory for the ii-th day (1im1 \le i \le m) is x+i1x + i - 1. These mm days of memories are concatenated in order to form a sequence of length mm.

In her dreams, this memory sequence is repeated kk times in order. Afterward, to awaken Susan, Luvia intervenes in the dream, inserting foreign memories not belonging to Susan. The final result is a sequence a1,a2,,ana_1, a_2, \ldots, a_n of length nn.

Given this sequence and kk, Luvia wants to determine the maximum possible value of mm for every possible base memory xx where 1xV1 \le x \le V. If no valid memory sequence exists for a particular xx, output 00.

Input Format

  • The first line contains three integers nn, kk, VV, as described.
  • The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n, representing the final sequence.

Output Format

Output one line containing VV integers, where the ii-th integer represents the maximum possible mm when x=ix = i.

9 2 5
2 1 3 4 5 2 3 2 4
0 3 2 1 0
30 3 8
3 4 5 5 1 2 8 4 5 3 6 4 5 7 5 6 6 7 6 8 7 1 8 2 3 2 7 3 7 8
0 2 1 2 1 2 2 1

Hint

Sample Explanation #1

For x=2x = 2 and m=3m = 3, Susan's memory sequence is 2 3 4. Repeating k=2k = 2 times gives 2 3 4 2 3 4. After inserting values between positions 11 and 22, 33 and 44, and 55 and 66, the sequence matches the original input.

Similarly, sequences like 2, 3, 4, 2 3, and 3 4 are all valid.

Data Range

This problem uses subtasks with bundled testing.

  • Subtask 1 (13 pts): n100n \le 100.
  • Subtask 2 (21 pts): n3000n \le 3000.
  • Subtask 3 (23 pts): n3×104n \le 3 \times 10^4.
  • Subtask 4 (25 pts): n5×105n \le 5 \times 10^5.
  • Subtask 5 (18 pts): No additional constraints.

For all data: 1kn2×1061 \le k \le n \le 2 \times 10^6, 1aiVn1 \le a_i \le V \le n.

Translation by DeepSeek R1