report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Knight's tour - FlandreOJ: Flandre Online Judge

Knight's tour

Time limit: 2000 ms
Memory limit: 256 MB
Given a chessboard of size $n \times m$, find a sequence of moves for a knight on a chessboard, such that the knight visits every square exactly once. Initially, you can place the knight at any position. ### Input - A single line contains two integers $n,m$. ### Output - Print a matrix of size $n\times m$ representing the order of visiting, starting from $1$. ### Constraints - $1 \le n,m \le 7$. ### Example Input: ``` 5 5 ``` 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 ```
Backtracking
Binary string
ABC string
Subset sum
Subset
Permutations
Group division
Knight's tour
N-queens problem
Maximum path
Knapsack
Build array
Sudoku
Minesweeper
Travelling Salesman Problem
Word search
Topic
Complete Search
Rating 800
Solution (1) Solution