AT_abc451_e [ABC451E] Tree Distance

Description

Determine whether there exists a weighted undirected tree with $ N $ vertices satisfying the following condition. - For any two integers $ i $ and $ j $ with $ 1 \le i \lt j \le N $ , the distance between vertices $ i $ and $ j $ is $ A_{i,j} $ . Here, the distance between vertices $ i $ and $ j $ is defined as the sum of the weights of the edges on the unique simple path connecting these two vertices.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A_{1, 2} $ $ A_{1, 3} $ $ \ldots $ $ A_{1, N} $ $ A_{2, 3} $ $ \ldots $ $ A_{2, N} $ $ \vdots $ $ A_{N-1,N} $

Output Format

If a tree satisfying the condition exists, output `Yes`; otherwise, output `No`.

Explanation/Hint

### Sample Explanation 1 For example, the tree with the following edges satisfies the condition. - Edge $ (1, 2) $ has weight $ 2 $ . - Edge $ (2, 3) $ has weight $ 3 $ . - Edge $ (2, 4) $ has weight $ 2 $ . Thus, output `Yes`. ### Sample Explanation 2 No tree satisfying the condition exists. Thus, output `No`. ### Constraints - $ 2 \le N \le 3000 $ - $ 1 \le A_{i,j} \le 9999 $ - All input values are integers.