#P5884. The Flight Game
The Flight Game
The Flight Game
Jianjia is a young boy who loves playing games instead of giving straight answers. In this game, Taiwan is represented as a set of n cities numbered from 0 to n-1. Some pairs of cities might be connected by a bidirectional flight. Jianjia’s friend, Meiyu, will ask exactly r = \(\frac{n(n-1)}{2}\) queries—one for each unordered pair of cities—in the form: "Is there a direct flight between city u and city v?"
Meiyu wins if, after any prefix (i.e. after fewer than all r queries are answered), the responses given so far are enough to determine whether the overall network is connected (i.e. whether every pair of cities is connected, directly or indirectly). Otherwise, if she must wait until all r answers to decide the connectivity, then Jianjia wins.
To make the game even more interesting, Jianjia is allowed to fabricate his answers as the game unfolds. His responses may depend on the queries asked so far. Your task is to help Jianjia win the game by choosing his responses to ensure that, until all queries are answered, there always exist at least two completions for the remaining answers: one that results in a connected network and one that results in a disconnected network.
Hint: One valid strategy is to answer No
to every query. In that case, if one completion sets all remaining answers to No
the final network is disconnected, but if the remaining answers are chosen as Yes
, the final network can be connected. This guarantees that before the final answer, the connectivity is ambiguous.
inputFormat
The input begins with an integer n, the number of cities. Following that are r = \(\frac{n(n-1)}{2}\) lines, each containing two integers u and v, representing a query asking if there is a direct flight between city u and city v.
outputFormat
For each query, output a line containing your answer, which must be either Yes
or No
. To help Jianjia win the game, your answers must be chosen such that until all queries are answered, it remains ambiguous whether the final network is connected. As highlighted, one correct strategy is to output No
for every query.
sample
2
0 1
No
</p>