1368_Couples

2022-5-16 18:17| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-2-89503824381500-Problem List-采集的数据-后羿采集器.html

Pro.ID

1368

Title

Couples

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=1368

AC

16

Submit

41

Ratio

39.02%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    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
    1 4
    2 3
    5 6
    7 8

    2
    1 3
    2 4

    0

    Sample Output

    Yes
    No

    样例输入

    4
    1 4
    2 3
    5 6
    7 8

    2
    1 3
    2 4

    0

    样例输出

    Yes
    No

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部