A11001 | Okabe and Future Gadget Laboratory
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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!
Help Okabe determine whether a given lab is good!
输入格式
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}<=10^{5}$ ).
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}<=10^{5}$ ).
输出格式
Print "Yes" if the given lab is good and "No" otherwise.
You can output each letter in upper or lower case.
You can output each letter in upper or lower case.
输入输出样例
输入 #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".
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".
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted