CF821A.Okabe and Future Gadget Laboratory
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 ≤ x, y ≤ n and a__x, y ≠ 1, there should exist two indices s and t so that a__x, y = a__x, s + a__t, y, where a__i, j denotes the integer in i-th row and j-th column.
Help Okabe determine whether a given lab is good!
Okabe 在进行了一些疯狂的实验后,需要翻新未来科技实验室!该实验室被表示为一个 n×n 的整数方阵。一个“好”的实验室定义为:其中每一个不等于 1 的数,均可表示为同一行中的某个数与同一列中的某个数之和。换言之,对所有满足 1≤x,y≤n 且 ax,y=1 的下标对 (x,y),均应存在两个下标 s 和 t,使得
ax,y=ax,s+at,y,
其中 ai,j 表示第 i 行、第 j 列处的整数。
请帮助 Okabe 判断给定的实验室是否是“好”的!
输入格式
The first line of input contains the integer n (1 ≤ n ≤ 50) — the size of the lab.
The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is a__i, j (1 ≤ a__i, j ≤ 105).
输入的第一行包含整数 n(1 ≤ n ≤ 50)—— 实验室的尺寸。
接下来的 n 行每行包含 n 个以空格分隔的整数,表示网格的一行。第 i 行中的第 j 个整数为 ai,j(1 ≤ ai,j ≤ 105)。
输出格式
Print "Yes" if the given lab is good and "No" otherwise.
You can output each letter in upper or lower case.
如果给定的实验室是好的,则输出“Yes”,否则输出“No”。
每个字母可以输出为大写或小写。
输入输出样例
输入#1
3 1 1 2 2 3 1 6 4 1
输出#1
Yes
输入#2
3 1 5 2 1 1 1 1 2 3
输出#2
No
说明/提示
In the first sample test, the 6 in the bottom left corner is valid because it is the sum of the 2 above it and the 4 on the right. The same holds for every number not equal to 1 in this table, so the answer is "Yes".
In the second sample test, the 5 cannot be formed as the sum of an integer in the same row and an integer in the same column. Thus the answer is "No".
在第一个样例测试中,左下角的数字 6 是合法的,因为它等于其上方的数字 2 与右侧的数字 4 的和。表中所有不等于 1 的数字均满足这一性质,因此答案为 “Yes”。
在第二个样例测试中,数字 5 无法表示为同一行中某个整数与同一列中某个整数的和。因此答案为 “No”。
输入解题思路,AI测评打分。不知道怎么写?