Editorial for COCI '06 Contest 2 #6 Straža
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
The trenches are represented by line segments. Suppose no two line segments overlap. Then any three segments, such that each segment intersects both of the other two and the three intersections are distinct, form a solution – we can place the guards on the three intersections.
Because some line segments may overlap we need to preprocess the input, merging line segments that overlap until there are none left.
Time complexity:
Comments