Logo
(追記) (追記ここまで)

21013번 - Occult Square 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB47232156.757%

문제

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:

  • The integers in the square are between 0 and N, inclusive.
  • For all 1 ≤ i ≤ N, the number i appears at most i times in the square.
  • There are at least two distinct positive integers in the square.

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.

제한

예제 입력 1

5

예제 출력 1

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

2

예제 출력 2

-1

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2020 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /