Wooden Matrix
시간 제한2초메모리 제한2048 MB
대각선이 0인 대칭 행렬이 양의 가중치를 가진 어떤 트리의 모든 쌍 거리 행렬과 같은지 판정한다.
문제
Consider a square matrix of size consisting of non-negative integers. The matrix is symmetric with respect to the main diagonal, and the main diagonal itself contains only zeroes. Such a matrix is called wooden if there is an undirected tree on vertices with edges of positive lengths such that each cell of the matrix contains the distance between vertices and in this tree.
You are given a matrix. Check if it is wooden.
입력
The first line contains an integer : the size of the matrix (). Each of the following lines contains integers : the elements of the matrix (). The matrix is symmetric with respect to the main diagonal. There are zeros on the main diagonal and strictly positive integers outside it.
출력
Print "Yes" or "No" depending on whether the matrix is wooden. Letter case does not matter.