아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Intervals

시간 제한1초메모리 제한512 MB

요약
길이가 같은 n개 구간의 모든 쌍별 교집합 길이가 주어질 때, 그런 구간이 실제로 존재할 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
구간, 그리디, 정렬, 수학
정답자
아직 제출이 없습니다

문제

Bobo draws nn intervals on the axis, which are conveniently numbered by 1,2,…,n1, 2, \dots, n. As an excellent mathematician, he managed to set all nn intervals of length 10610^6.

Then bobo carefully computes I_i,jI\_{i, j}, the length of the intersection of intervals ii and jj, and discards all intervals. However, bobo wants to check his calculations and he is eager to know whether the result can be correct.

In another word, determine if there exists nn intervals of length 10610^6 providing the same result.

입력

The first line contains an integer nn (1≤n≤10001 \leq n \leq 1000).

Each of the following nn lines contains nn integers I_i,1,I_i,2,…,I_i,nI\_{i, 1}, I\_{i, 2}, \dots, I\_{i, n} (0≤I_i,j≤1060 \leq I\_{i, j} \leq 10^6).

Since bobo knows math well, it is guaranteed that I_i,j=I_j,iI\_{i, j} = I\_{j, i} and I_i,i=106I\_{i, i} = 10^6.

출력

If for given I_i,jI\_{i,j} it is possible to find at least one appropriate set of intervals, print "Yes". Otherwise, print "No".

예제2

  1. 예제 1

    입력
    3
    1000000 500000 0
    500000 1000000 500000
    0 500000 1000000
    
    예상 출력
    Yes
    
  2. 예제 2

    입력
    3
    1000000 500000 500000
    500000 1000000 500000
    500000 500000 1000000
    
    예상 출력
    No