22244_StillJohnnyCan'tAdd

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

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

Pro.ID

22244

Title

Still Johnny Can't Add

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    One way for young children in elementary schools to practice addition is to make them write down an addition table. An addition table of size N is an (N + 1) * (N + 1) square matrix, where the top row and the left column are labeled with some random integers, (except for their intersection cell where we normally put the plus sign.) The child's task is now to put in each cell the result of adding the label of the row, and the label of the column. For example, the table on the right is an addition table of size 3.

    Once students grow up and enter intermediate-level schools, we can give them the opposite. Give them an N*N table, and let them decide how to add labels for it to be a valid addition table (if it is indeed an addition table.) Given an N*N table, which does not include any labels, your job is to decide whether it is possible to properly label it or not. We're not interested in the labels themselves, just decide if it is an addition table or not. For example, the 2 * 2 table on the left is not an addition table, while the one on the right is.

    输入

    Your program will be tested on one or more test cases. The first line in the input is an integer D representing the number of cases. The first line of each test case is an integer N, where N ≤ 10, representing the size of the table. Following that, there will be N lines, each with N integers representing the N*N table in a row-major format. Each number in the table is between -10,000 and 10,000 (inclusive).

    输出

    Description

    One way for young children in elementary schools to practice addition is to make them write down an addition table. An addition table of size N is an (N + 1) * (N + 1) square matrix, where the top row and the left column are labeled with some random integers, (except for their intersection cell where we normally put the plus sign.) The child's task is now to put in each cell the result of adding the label of the row, and the label of the column. For example, the table on the right is an addition table of size 3.

    Once students grow up and enter intermediate-level schools, we can give them the opposite. Give them an N*N table, and let them decide how to add labels for it to be a valid addition table (if it is indeed an addition table.) Given an N*N table, which does not include any labels, your job is to decide whether it is possible to properly label it or not. We're not interested in the labels themselves, just decide if it is an addition table or not. For example, the 2 * 2 table on the left is not an addition table, while the one on the right is.

    Input

    Your program will be tested on one or more test cases. The first line in the input is an integer D representing the number of cases. The first line of each test case is an integer N, where N ≤ 10, representing the size of the table. Following that, there will be N lines, each with N integers representing the N*N table in a row-major format. Each number in the table is between -10,000 and 10,000 (inclusive).

    Output

    For each test case, output the result on a single line using the following format:

    k. result

    Where k is the test case number (starting at 1,) and result is "YES" if the test case is an addition table, or "NO" if it's not.

    Sample Input

    3
    3
    4 -1 6
    7 2 9
    1 -4 3
    2
    1 4
    3 5
    2
    3 6
    2 5

    Sample Output

    1. YES
    2. NO
    3. YES

    Source

    样例输入

    3
    3
    4 -1 6
    7 2 9
    1 -4 3
    2
    1 4
    3 5
    2
    3 6
    2 5

    样例输出

    1. YES
    2. NO
    3. YES

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部