English · Original
Chinese · Translation
Formal · Original
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_!
## Input
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).
## Output
Print "_Yes_" if the given lab is _good_ and "_No_" otherwise.
You can output each letter in upper or lower case.
[samples]
## Note
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_".
Okabe 需要在进行了一些疯狂的实验后翻新 _Future Gadget 实验室_!该实验室由一个 #cf_span[n] × #cf_span[n] 的整数方格表示。一个 _好_ 的实验室定义为:每个不等于 #cf_span[1] 的数都可以表示为同一行中的某个数与同一列中的某个数之和。换句话说,对于每个满足 #cf_span[1 ≤ x, y ≤ n] 且 #cf_span[ax, y ≠ 1] 的位置 #cf_span[x, y],都应存在两个下标 #cf_span[s] 和 #cf_span[t],使得 #cf_span[ax, y = ax, s + at, y],其中 #cf_span[ai, j] 表示第 #cf_span[i] 行第 #cf_span[j] 列的整数。
帮助 Okabe 判断给定的实验室是否为 _好_ 的!
输入的第一行包含整数 #cf_span[n](#cf_span[1 ≤ n ≤ 50])——实验室的大小。
接下来的 #cf_span[n] 行每行包含 #cf_span[n] 个用空格分隔的整数,表示网格的一行。第 #cf_span[i] 行的第 #cf_span[j] 个整数是 #cf_span[ai, j](#cf_span[1 ≤ ai, j ≤ 105])。
如果给定的实验室是 _好_ 的,输出 "_Yes_";否则输出 "_No_"。
你可以以任意大小写输出每个字母。
在第一个样例中,左下角的 #cf_span[6] 是合法的,因为它等于其上方的 #cf_span[2] 与右侧的 #cf_span[4] 之和。表中所有不等于 #cf_span[1] 的数都满足这一性质,因此答案为 "_Yes_"。
在第二个样例中,#cf_span[5] 无法表示为同一行和同一列中任意两个整数的和,因此答案为 "_No_"。
## Input
输入的第一行包含整数 #cf_span[n](#cf_span[1 ≤ n ≤ 50])——实验室的大小。接下来的 #cf_span[n] 行每行包含 #cf_span[n] 个用空格分隔的整数,表示网格的一行。第 #cf_span[i] 行的第 #cf_span[j] 个整数是 #cf_span[ai, j](#cf_span[1 ≤ ai, j ≤ 105])。
## Output
如果给定的实验室是 _好_ 的,输出 "_Yes_";否则输出 "_No_"。你可以以任意大小写输出每个字母。
[samples]
## Note
在第一个样例中,左下角的 #cf_span[6] 是合法的,因为它等于其上方的 #cf_span[2] 与右侧的 #cf_span[4] 之和。表中所有不等于 #cf_span[1] 的数都满足这一性质,因此答案为 "_Yes_"。在第二个样例中,#cf_span[5] 无法表示为同一行和同一列中任意两个整数的和,因此答案为 "_No_"。
**Definitions**
Let $ n \in \mathbb{Z} $ be the size of the grid.
Let $ A = (a_{i,j}) \in \mathbb{Z}^{n \times n} $ be the grid, where $ a_{i,j} $ denotes the integer in row $ i $, column $ j $.
**Constraints**
1. $ 1 \leq n \leq 50 $
2. $ 1 \leq a_{i,j} \leq 10^5 $ for all $ i, j \in \{1, \dots, n\} $
**Objective**
Determine whether for every cell $ (x, y) $ such that $ a_{x,y} \neq 1 $, there exist indices $ s, t \in \{1, \dots, n\} $ satisfying:
$$
a_{x,y} = a_{x,s} + a_{t,y}
$$
If this holds for all such $ (x,y) $, output "Yes"; otherwise, output "No".
API Response (JSON)
{
"problem": {
"name": "A. Okabe and Future Gadget Laboratory",
"description": {
"content": "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",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF821A"
},
"statements": [
{
"statement_type": "Markdown",
"content": "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...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "Okabe 需要在进行了一些疯狂的实验后翻新 _Future Gadget 实验室_!该实验室由一个 #cf_span[n] × #cf_span[n] 的整数方格表示。一个 _好_ 的实验室定义为:每个不等于 #cf_span[1] 的数都可以表示为同一行中的某个数与同一列中的某个数之和。换句话说,对于每个满足 #cf_span[1 ≤ x, y ≤ n] 且 #cf_span[ax, y ≠ ...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ n \\in \\mathbb{Z} $ be the size of the grid. \nLet $ A = (a_{i,j}) \\in \\mathbb{Z}^{n \\times n} $ be the grid, where $ a_{i,j} $ denotes the integer in row $ i $, column $ j $.\n\n...",
"is_translate": false,
"language": "Formal"
}
]
}