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

5264번 - spiral123 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB28181575.000%

문제

We shall name a square matrix as spiral123 if it has the following properties:

  • its elements are from the {0, 1, 2, 3} set;
  • each row and column contains each of the values 1, 2 and 3, exactly once and all the other values are 0;
  • starting from the upper-left corner going right, moving in spiral, the non-zero values will appear in the following order 1, 2, 3, 1, 2, 3, ... , 1, 2, 3.

For example a 5x5 spiral123 matrix is the following:

For a given natural number n, you should generate a n x n spiral123 matrix.

입력

The input contains only one natural number n on the first line.

출력

If there is solution, output must contain n lines, each with n numbers separated with one space, representing the required matrix. If there is no solution, on the single line of the output file, the -1 value will be written.

제한

  • 5 ≤ n ≤ 200;
  • There can be many solutions, any of them can be written.

예제 입력 1

5

예제 출력 1

0 1 0 2 3
0 2 3 0 1
1 3 0 0 2
3 0 2 1 0
2 0 1 3 0

힌트

Another correct solution would be:

0 1 2 3 0
2 3 0 0 1
0 0 3 1 2
1 0 0 2 3
3 2 1 0 0

출처

Olympiad > Balkan Olympiad in Informatics > Junior Balkan Olympiad in Informatics > JBOI 2011 6번

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

출처

대학교 대회

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

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