Pro.ID22244 TitleStill Johnny Can't Add Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22244 AC0 Submit0 Ratio- 时间&空间限制描述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 Sample Output 1. YES Source 样例输入3 样例输出1. YES 作者 |