Matrices and Sums
시간 제한1초메모리 제한2048 MB
원소가 -1, 0, 1인 n x n 행렬을 만들어 n개의 행 합과 n개의 열 합이 모두 다르게 하거나, 불가능하면 불가능하다고 답한다.
문제
Given a positive integer , you should construct an integer matrix satisfying the following conditions:
- For all elements (), the absolute value .
- The row and column sums are pairwise distinct, where and .
There may exist multiple solutions or no solution.
입력
The first line contains a single integer ().
출력
The first line must contain one string "Yes" (without quotes) if a solution exists, or "No" (without quotes) if there is no solution.
When a solution exists, print more lines, each containing integers, denoting the matrix you construct.
If multiple solutions exist, print any one of them.
힌트
- In the first example, , , , and are all distinct.
- In the second example, always holds, so no solution exists.