Editorial for COCI '16 Contest 5 #4 Ronald
Submitting an official solution before solving the problem yourself is a bannable offence.
For any line - we deduce: each Krump's selection of city or city changes its existence, so its final existence depends only on the parity of the number of selections of cities and . Given this fact, it is sufficient to assume that Krump selects each city zero or one time (selection or non-selection), which greatly simplifies the task.
We investigate two options: Krump either selects city , or he doesn't. For each of the possibilities, we will check whether they can lead to a complete graph. If we've fixed the selection (or non-selection) of city , for each other city we can easily determine if it needs to be selected, considering the parity that must enable the existence of flight route -. This way, we determine the selections or non-selections of all cities from to . Since we've only ensured the existence of flight routes -, we will check the existence of all other lines, and if all of them exist, the answer is DA
(Croatian for "yes").
An alternative solution is the following: the answer is DA
(Croatian for "yes") if and only if the initial graph consists of exactly two components, each of them being a complete graph (clique). The proof is left as an exercise for the reader.
Comments