6790.Knight's Tour---TODO

Time Limit: 1s Memory Limit: 512MB

Given a starting position of a knight on an $8 \times 8$ chessboard, your task is to find a sequence of moves such that it visits every square exactly once.

On each move, the knight may either move two steps horizontally and one step vertically, or one step horizontally and two steps vertically.

Input Format(From the terminal/stdin)

The only line has two integers $x$ and $y$ : the knight's starting position.

  • $1 \le x,y \le 8$

Output Format(To the terminal/stdout)

Print a grid that shows how the knight moves (according to the example). You can print any valid solution.

Sample Input

Copy
2 1
 · \n

Sample Output special judge

Copy
8 1 10 13 6 3 20 17 
11 14 7 2 19 16 23 4 
26 9 12 15 24 5 18 21 
49 58 25 28 51 22 33 30 
40 27 50 59 32 29 52 35 
57 48 41 44 37 34 31 62 
42 39 46 55 60 63 36 53 
47 56 43 38 45 54 61 64
 · ·  ·  · · ·  ·  \n
  ·  · · ·  ·  ·  · \n
  · ·  ·  ·  · ·  ·  \n
  ·  ·  ·  ·  ·  ·  ·  \n
  ·  ·  ·  ·  ·  ·  ·  \n
  ·  ·  ·  ·  ·  ·  ·  \n
  ·  ·  ·  ·  ·  ·  ·  \n
  ·  ·  ·  ·  ·  ·  ·  \n
Source: CSES, Graph Algorithms, 1689

Submit

请先 登录

© 2025 FAQs