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

19168번 - Brainy 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB611100.000%

문제

Brainy Smurf invented a new ($n \times n$) SmurfBoard which looks just like a normal chessboard except that the left edge is glued to the right edge and the top edge is glued to the bottom edge (don't ask how it's possible, it's patented by Brainy in Smurf Patent Office). As usual, the other Smurfs were not interested in his invention so he went to Papa Smurf:

  • "Papa Smurf! No one cares about my SmurfBoard!"
  • "What does it do?"
  • "Well... nothing... yet."
  • "Is it at least colorful? Smurfs love colorful things."
  • "No... not yet."
  • "Then you should color it, but it can't be any ordinary coloring. You should color it in such a way that each possible coloring of a 2ドル \times 2$ square appears exactly once."

The SmurfBoard is so fragile that it cannot be rotated or flipped. Brainy being so smart immediately concluded that for $k$ colors there are $k^4$ combinations so he'll need $n = k^2$. But finding desired coloring for any $k$ larger than two is beyond even Brainy's skills. Maybe you can help him?

입력

First and only input line contains $k$ ($k \leq 40$ and $k$ is prime) -- the number of colors to be used. The dimensions of desired SmurfBoard are $n \times n$ where $n = k^2$.

출력

Output $n$ lines with $n$ integers each specifying any correct coloring (colors are numbered from 1ドル$ to $k$). If it is not possible to color the SmurfBoard then on a single line output the word "NO" (without quotes).

제한

예제 입력 1

2

예제 출력 1

1 2 1 1
1 2 2 2
2 2 2 1
1 1 2 1

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2015 > Day 5: U of Wroclaw Contest B번

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

출처

대학교 대회

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

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