21641_BoredS

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

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

Pro.ID

21641

Title

Bored S

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    One day, S was so bored that he did something boring like this.

    He drew N points on the paper, and added a loop, that is, an edge connecting a point and itself, on each point. Then, he added several edges between different points, randomly. It's guaranteed that there was no more than one edge between a pair of points. So, there he gained an undirected graph G without any parallel edge. Finally, he figured out the adjacent matrix A of the graph G, and calculated A2.

    Here you're given only the finally matrix A2, S wants to know whether there is a way to travel all the edges on graph G once and exactly once, and end at the point where the journey starts. Could you answer him?

    输入

    The first line is an integer T ( T ≤ 20 ), indicating the number of test cases. Each case is in the format like this:

    First line is a positive integer N ( N ≤ 100 ), indicating the number of points of the graph. Then there are N lines following, with N space-separated integers on each line. The j-th integer on the i-th line is the (i, j) element of matrix A2.

    输出

    Description

    One day, S was so bored that he did something boring like this.

    He drew N points on the paper, and added a loop, that is, an edge connecting a point and itself, on each point. Then, he added several edges between different points, randomly. It's guaranteed that there was no more than one edge between a pair of points. So, there he gained an undirected graph G without any parallel edge. Finally, he figured out the adjacent matrix A of the graph G, and calculated A2.

    Here you're given only the finally matrix A2, S wants to know whether there is a way to travel all the edges on graph G once and exactly once, and end at the point where the journey starts. Could you answer him?

    Input

    The first line is an integer T ( T ≤ 20 ), indicating the number of test cases. Each case is in the format like this:

    First line is a positive integer N ( N ≤ 100 ), indicating the number of points of the graph. Then there are N lines following, with N space-separated integers on each line. The j-th integer on the i-th line is the (i, j) element of matrix A2.

    Output

    For each test case, print one line with the string "Yes" or "No" (quotes for clarity), according to your answer to the question above.

    Sample Input

    2
    1
    1
    2
    2 2
    2 2

    Sample Output

    Yes
    No

    Hint

    B = A2

    if and only if

    ( A is an n*n matrix and the elements are 0-based )

    Source

    样例输入

    2
    1
    1
    2
    2 2
    2 2

    样例输出

    Yes
    No

    提示

    B = A2

    if and only if

    ( A is an n*n matrix and the elements are 0-based )


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部