ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Ural SU contest. Petrozavodsk training camp. Summer 2008

About     Problems     Submit solution     Judge status     Standings
Contest is over

E. Drunk King

Time limit: 1.0 second
Memory limit: 64 MB
Drunk king is a piece which moves as a usual chess king (i. e. to one of eight adjacent cells), but cannot make two consecutive moves in the same direction. Drunk king stands in an upper-left corner of an N × M chessboard and wants to visit each cell exactly once and return to initial position. His path must have no self-intersections.
Here are the examples of correct tours:
Problem illustration
Help the king to find the required tour.


The only input line contains 2 integers: N and M (2 ≤ N, M ≤ 500).


In the first line output “Yes” or “No” depending on whether the required tour exists. If the tour exists, output it in the next 2N − 1 lines with symbols “o” (ASCII code 111), “|” (code 124), “-” (code 45), “/” (code 47), “\” (code 92) and spaces. Each of these lines should contain exactly 2M − 1 symbols. Use the format shown in the sample below. If there are many tours, you can output any of them.


6 8
o-o o-o o-o o-o
|  \| |/  |/  |
o-o o o o o o-o
  |    / \   \ 
o-o o-o o-o o-o
|    \   \   \ 
o-o o-o o-o o-o
  |  \   \   \ 
o-o o o o-o o o
|  /| | |  /| |
o-o o-o o-o o-o
5 5
Problem Author: Igor Chevdar
Problem Source: Ural SU Contest. Petrozavodsk Summer Session, August 2008
To submit the solution for this problem go to the Problem set: 1674. Drunk King