시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 20 | 12 | 10 | 62.500% |
A magic square is a square array of non-negative integers where the sums of the numbers on each row, each column, and both main diagonals are the same. An N × N occult square is a magic square with N rows and N columns with additional constraints:
For example, the following is a 5 × 5 occult square, where the sums of the numbers on each row, each column, and both main diagonals are 7:
0 0 0 3 4 2 4 0 0 1 0 0 3 4 0 5 0 0 0 2 0 3 4 0 0
For a given prime number P, you are asked to construct a P × P occult square, or determine whether no such occult square exists.
Input contains a prime number: P (2 ≤ P ≤ 1000) representing the number of rows and columns in the occult square.
If there is no P × P occult square, simply output -1 in a line. Otherwise, output P lines, each contains P integers representing an occult square. The jth integer on the ith line is the integer on the ith row and the jth column in the occult square. You may output any P × P occult square.
5
0 0 0 3 4 2 4 0 0 1 0 0 3 4 0 5 0 0 0 2 0 3 4 0 0
2
-1
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2020 E번