#P4753. River Jumping

    ID: 3607 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>模拟搜索贪心Special JudgeO2优化洛谷月赛

River Jumping

Description

There is a river of width NN. Little D is on the bank at coordinate 00. He wants to reach the bank at coordinate NN and then return to coordinate 00. Before reaching the bank at coordinate NN, Little D can only jump to positions with larger coordinates. After reaching the bank at coordinate NN, Little D can only jump to positions with smaller coordinates. There are MM rocks in the river. Little D hopes to land on each rock exactly once. Because Little D can jump very far, his jump length has a lower bound SS but no upper bound. Now determine whether he can achieve his goal.

Input Format

The first line contains three integers N,M,SN, M, S, representing the width of the river, the number of rocks, and the lower bound of the jump length.

The second line contains MM integers, representing the coordinates of the MM rocks: w1,w2,,wNw_1, w_2, \cdots, w_N. It is guaranteed that {wi}\{w_i\} is a strictly increasing sequence.

Output Format

If Little D can achieve his goal, output YES on the first line, and output M+2M + 2 numbers on the second line, in order, representing the indices of the stones that Little D lands on. In particular, the bank at coordinate 00 has index 00, and the bank at coordinate NN has index M+1M + 1. If there are multiple solutions, you may output any one of them.

If Little D cannot achieve his goal, output NO on the first line.

6 1 3
3
YES
1 2 0
6 2 2
2 4
YES
2 3 1 0
5 2 3
2 3
NO

Hint

For all testdata, it is guaranteed that 1N,S1000001 \le N, S \le 100000, 0M<N0 \le M < N, and 1wi<N1 \le w_i < N.

Translated by ChatGPT 5