ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Переборные задачи > задача:


50714 - The knight

Гость
• Обсуждение задачи (1)

Задачи раздела

• 50367 - Bar Codes
• 50265 - Liars and Knights
• 51071 - Phalanx-2
• 50479 - Bit Compressor
• 50486 - Problems and Programmers
• 50712 - Moon algebra
• 50714 - The knight
• 50717 - Hurdle Jumping
• Check-Mate
• 50710 - Permutations
• 50709 - k-ary Strings
• 50708 - Binary Strings
• 50996 - Checkers - the shortest path
• 51067 - Jumping frog
• Post Office Delivery

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Prepared by: Ilir Capuni.

The Knight

Suppose that you are given a chess board with n x n fields. A knight is set at position (x,y).

Write a program that draws the path of n^2-1 moves, such that the knight visits each field exactly once.

The knight moves in a ‘L’ fashion, meaning that it can do two moves and then turn in both x and y direction.

Input description: You will be given an integer n (4<=n<=6) and two integers x and y (1<=x,y<=n) representing the coordinates of the position where the knight starts.

Note: The coordinates of the knight start from 1 to n with (1,1) being the upper left corner of the matrix.

Output description: Show one possible solution of the puzzle in a nxn matrix or “Impossible” if not possible.

 

Sample 1

Sample 2

Input:

5

1 1

6

1 1

Output:

1 6 15 10 21

14 9 20 5 16

19 2 7 22 11

8 13 24 17 4

25 18 3 12 23

1 12 21 28 7 10

22 29 8 11 20 27

13 2 23 4 9 6

30 35 32 17 26 19

33 14 3 24 5 16

36 31 34 15 18 25

Explaination for sample 1:
The knight starts at (1,1) so this is his first position. Then it moves to (2, 3) so we put 2 here as this is his second position. Then it moves to (5,3) so this is it’s 3rd position. And so on with the cell (1,5) being it’s 25th and last position.

Для отправки решений необходимо выполнить вход.

www.contester.ru