#P3588. [POI 2015 R2] 沙漠 Desert
[POI 2015 R2] 沙漠 Desert
Description
Given a positive integer sequence of length , where each number is in the range to . You are told of the numbers, and given pieces of information. Each piece contains three numbers followed by positive integers, meaning that among , each of the values at those positions is strictly greater than each of the values at the remaining positions (strictly greater; no equality).
Construct any sequence that satisfies all the conditions, or determine that there is no solution.
Input Format
The first line contains three positive integers (, ). The next lines each contain two positive integers , meaning . It is guaranteed that the are in increasing order.
The next lines: each line begins with three positive integers (, ), followed by positive integers (), indicating that in , each of these positions has a value strictly greater than each of the other positions. (.)
Output Format
If there is no solution, output NIE. Otherwise, output TAK on the first line, and on the second line output positive integers, the sequence in order.
5 2 2
2 7
5 3
1 4 2 2 3
4 5 1 4
TAK
6 7 1000000000 6 3
3 2 1
2 3
3 5
1 3 1 2
NIE
2 1 1
1 1000000000
1 2 1 2
NIE
Hint
Original title: Pustynia.
Two additional sample tests are provided and can be downloaded from the attachments.
Translated by ChatGPT 5
京公网安备 11011102002149号