#P15057. [UOI 2023 II Stage] Roads of Potokolandiya
[UOI 2023 II Stage] Roads of Potokolandiya
题目描述
In Potokoland, there are cities and two-way roads. The -th road connects cities and (if , then ).
For example, if , the roads will be , , , , and .
Determine if it is possible to travel from any city to any other city using the roads. If not, find a pair of cities that are not connected.
输入格式
The first line contains one integer ().
输出格式
Output if it is possible to travel from any city to any other city.
Otherwise, output on the first line. On the second line, output any two cities and (; ) such that it is impossible to travel from to using the roads.
5
NO
1 5
4
YES
7
NO
1 7
8
YES