Pro.ID1368 TitleCouples Title链接http://10.20.2.8/oj/exercise/problem?problem_id=1368 AC16 Submit41 Ratio39.02% 时间&空间限制描述N couples are standing in a circle, numbered consecutively clockwise from 1 to 2N. Husband and wife do not always stand together. We remove the couples who stand together until the circle is empty or we can't remove a couple any more. Can we remove all the couples out of the circle? 输入There may be several test cases in the input file. In each case, the first line is an integer N (1 ≤ N ≤ 100000 ) ---- the number of couples. In the following N lines, each line contains two integers ---- the numbers of each couple.N = 0 indicates the end of the input. 输出Description N couples are standing in a circle, numbered consecutively clockwise from 1 to 2N. Husband and wife do not always stand together. We remove the couples who stand together until the circle is empty or we can't remove a couple any more. Can we remove all the couples out of the circle? Input There may be several test cases in the input file. In each case, the first line is an integer N (1 ≤ N ≤ 100000 ) ---- the number of couples. In the following N lines, each line contains two integers ---- the numbers of each couple.N = 0 indicates the end of the input. Output Output "Yes" if we can remove all the couples out of the circle. Otherwise, output "No". Sample Input 4 Sample Output Yes 样例输入4 样例输出Yes 提示作者 |