#P3634. [APIO2012] 守卫
[APIO2012] 守卫
Description
In front of the castle, there are bushes, numbered from to . There are ninjas hiding behind exactly bushes.
There are guards in the APIO castle. Guard watches a contiguous segment of bushes numbered from to . Each guard reports to the king whether there is a ninja within their monitored range.
As the king’s servant, you need to tell the king, based on the guards’ reports, which bushes must contain a ninja; that is, for any placement of ninjas that is consistent with the reports, there is a ninja behind that bush.
Output all such bush indices.
Input Format
The first line contains three space-separated integers . is the number of bushes, is the number of ninjas, and is the number of guards.
The next lines each describe one guard. The -th line contains three integers , meaning that the -th guard monitors the range from to (with ). is or : means no ninja is seen within the range; means there is at least one ninja within the range.
The input guarantees that at least one placement of ninjas satisfies all constraints.
Output Format
If there exist bushes that must contain a ninja, output their indices in increasing order, one per line. If there are such bushes, output lines.
Otherwise, output a single line containing -1.
5 3 4
1 2 1
3 4 1
4 4 0
4 5 1
3
5
5 1 1
1 5 1
-1
Hint
Sample Explanation
In this sample, there are two possible placements: or . Therefore, and must contain a ninja. For bush , there exists a placement where it has a ninja and another where it does not, so should not be output. Similarly, should not be output.
Sample Explanation
In this sample, no bush is guaranteed to contain a ninja.
Constraints
; ; .
For of the testdata, , .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号