CF821A.Okabe and Future Gadget Laboratory

普及/提高-

通过率:0%

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 nn by nn square grid of integers. A good lab is defined as a lab in which every number not equal to 11 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,yx,y such that 1<=x,y<=n1<=x,y<=n and ax,y1a_{x,y}≠1 , there should exist two indices ss and tt so that ax,y=ax,s+at,ya_{x,y}=a_{x,s}+a_{t,y} , where ai,ja_{i,j} denotes the integer in ii -th row and jj -th column.

Help Okabe determine whether a given lab is good!

输入格式

The first line of input contains the integer nn ( 1<=n<=501<=n<=50 ) — the size of the lab.

The next nn lines contain nn space-separated integers denoting a row of the grid. The jj -th integer in the ii -th row is ai,ja_{i,j} ( 1<=ai,j<=1051<=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.

输入输出样例

  • 输入#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 66 in the bottom left corner is valid because it is the sum of the 22 above it and the 44 on the right. The same holds for every number not equal to 11 in this table, so the answer is "Yes".

In the second sample test, the 55 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".

首页