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

31107번 - Knight’s Move 스페셜 저지다국어

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

문제

Several years ago a chessboard was a square $n \times n$ in size (considering that $n$ was even), divided into squares 1ドル \times 1$ in size. However, after all these years many things have changed in the Chess Kingdom.

The magical progress never stops and during the trials of the newest mass destruction weapon two corner squares of a chessboard, $(1,1)$ and $(n,n),ドル were destroyed. Besides, the court magicians learned about a parallel world's existence – the so-called {\itshape Through the Looking Glass}, located at the other side of the board. They even learned to move from any chessboard square to the corresponding Through the Looking Glass square (to the square that is located exactly under the given square) and back again using special portals.

The White King wanted to visit once more all the squares of his kingdom with his devoted friend. His friend, that is, the Knight moves according to usual chess rules, namely: first it moves two squares in one direction, then changes the movement direction by 90 degrees (to the left or to the right) and moves one other square. In the Through the Looking Glass the Knight moves in perfectly the same manner. Besides, the King has a pocket portal using which he and the Knight can travel to Through the Looking Glass and back. We have to note that using the portal, as well as the Knight's move, is considered to be a move as well.

Help the White King and find some movement path. Each of the 2ドルn^2-4$ chessboard squares should be visited exactly once. Besides, the path should be closed, that is, one should be able to go from the first square of the path to the last one in one move. The court Wisemen proved that such path exists.

입력

You are given an even integer $n$ (4ドル \le n \le 100$).

출력

Print 2ドルn^2-4$ lines. The $i$-th line should describe the Knight's position at the beginning of the $i$-th move in the following format: $x$ $y$ $w$ (1ドル \le x, y \le n, 0 \le w \le 1$). $x$ and $y$ are the coordinates of the square, $w$ is the world where the Knight and the King are located: 0ドル$ for the normal world and 1ドル$ for Through the Looking Glass. All squares should be different. There shouldn't be such squares as "1 1 0", "1 1 1", "n n 0", "n n 1". It is allowed to start the path from any cell. See the sample for clarifications.

If there are several solutions, print any of them.

제한

예제 입력 1

4

예제 출력 1

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

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 16: Grand Prix of Urals K번

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

출처

대학교 대회

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

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