eolymp
bolt
Try our new interface for solving problems

Camel

Zaman məhdudiyyəti 0.45 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB

Camel

Let’s describe a new “chess” piece and call it “camel-tone”. The piece moves jumping: horizontally or vertically – over two chessboard squares, or diagonally – over one square. The picture shows a part of the board with a camel-tone, placed in the center and the positions (marked by x), where it can go with one move. Of course, it cannot go outside the playing board, which happens to be a big square, divided into N×NN\times NN×N little squares. In this task NNN is always divisible by 555.

The camel-tone starts at the square in the top-left corner of the board. The game consists of making a sequence of moves on the board, visiting every square exactly once. Moreover, after N2−1N^2-1N​2​​−1 moves the piece should be exactly one move away from its starting position. This is a so-called “camel-tonian cycle”!

Nümunə

Giriş verilənləri #1
10
Çıxış verilənləri #1
1 52 29 8 51 28 9 50 37 16
85 95 59 86 94 66 87 93 65 88
40 19 100 39 18 76 38 17 77 49
2 53 30 7 58 27 10 89 36 15
84 96 60 75 99 67 72 92 64 71
41 20 82 44 23 90 45 24 78 48
3 54 31 6 57 26 11 68 35 14
83 97 61 74 98 62 73 91 63 70
42 21 81 43 22 80 46 25 79 47
4 55 32 5 56 33 12 69 34 13