#P11024. [COTS 2020] 定序 Redoslijed
[COTS 2020] 定序 Redoslijed
Background
Translated from Izborne Pripreme 2020 (Croatian IOI/CEOI Team Selection) D1T2。。
Acknowledgement: SPJ by
Problem Description
You are painting on a wooden board of length 。The board is divided from left to right into cells, and each cell is long。
It is known that strokes were painted on the board。The -th stroke paints cells into color 。
Given the final state of the board after all painting, construct an order of operations such that after performing the operations once, the board becomes exactly the given final state, or report that there is no solution。
Input Format
The first line contains two positive integers 。
The next lines each contain three integers , describing a painting operation。
The next line contains integers。The -th integer denotes the final color of the -th cell。In particular, if , it means the cell with is unpainted.
Output Format
If there is no solution, output (Croatian for “No”)。
Otherwise, output (Croatian for “Yes”) on the first line; on the second line output a permutation of indicating the painting order。
If there are multiple solutions, any one is acceptable。
6 5
3 5 5
1 1 6
1 3 2
1 4 7
4 6 6
6 2 5 5 5 6
DA
4 5 3 1 2
14 6
6 9 4
12 13 6
2 3 5
1 14 3
5 6 9
9 12 8
3 5 5 3 9 4 4 4 8 8 8 6 6 3
DA
4 5 1 6 2 3
15 5
7 8 3
10 14 5
4 7 2
3 12 1
5 9 4
0 0 1 2 4 4 3 3 4 5 1 1 5 5 0
NE
Hint
For of the testdata, it is guaranteed that:
- ;
- ;
- ;
- 。
| Subtask ID | Special property | Score | |
|---|---|---|---|
| A | |||
| B | |||
- Special property A: all are pairwise distinct。
- Special property B: 。
Translated by ChatGPT 5