#P10382. 「HOI R1」杂造选构
「HOI R1」杂造选构
Background
Little has nothing to do with this annoying construction problem.
Problem Description
A sequence is called valid if it satisfies the following requirements:
- or .
- For every , add a directed edge . The graph formed in this way has no cycles.
Now you are given an integer and a sequence , where all elements of are integers in the range . Please replace every position with by some other integer, so that and is valid. If no such solution exists, report that there is no solution.
Input Format
The first line contains two integers and .
The second line contains integers, representing the sequence . It is guaranteed that .
Output Format
If there is no solution, it means you were fooled, so output a string Rick. Otherwise output integers, representing the sequence after replacing all elements that are .
6 -6
-1 -1 -1 0 0 0
-1 -1 -1 -1 -1 -1
6 14
0 1 4 0 1 4
-1 1 4 5 1 4
6 10
0 0 0 0 0 0
-1 -1 4 5 -1 4
6 6
1 1 0 0 0 0
Rick
6 40
0 0 0 0 0 0
Rick
Hint
This problem uses bundled tests.
| Subtask | Score | Special property | ||
|---|---|---|---|---|
| #0 | None | |||
| #1 | ||||
| #2 | Yes | |||
| #3 | None |
*Special property: it is guaranteed that .
For all testdata, , .
Special Judge return value table
Accepted.The answer is correct.Oops, your answer is wrong. 1The correct answer has no solution, but the contestant output says there is a solution.Oops, your answer is wrong. 2The contestant’s output has .Oops, your answer is wrong. 3The contestant’s output contains .Oops, your answer is wrong. 4The contestant’s output contains a cycle.Oops, your answer is wrong. 5While filling in the blanks, the contestant modified positions where the input has .
Translated by ChatGPT 5