Chess with WishingBone
Time Limit: 1 Second Memory Limit: 32768 KB
WildLeopard and WishingBone love chess (west chess not chinese chess) very much. They play together every day.
One day, after reached the final phase of a game of chess, they found that WishingBone left his King and one Rook. But WildLeopard left only the King.
As known, WildLeopard held the Black.
So, give you the initial position of the three chesses, and whose turn it is, could you judge out whether Leopard could win?
The rule of the chess:
1. The King could go down, up, left, right, up-left, down-left, up-right, down-right, eight directions to the nearby grid, unless it go outside the pad.
2. The Rook could go down, up, left, right, four directions to any grid, unless it go outside the pad or be trapped by other chess.
3. The King and the Rook could eat opposite's chess if the target is on his way.
4. The King and the Rook could never eat chess on the same side.
5. The legal move means the move which does not betray his King.
6. There is a situation called Forced-Draw, which means when the player in turn can not make any legal move, and his King is not being attacked just now.
7. If the King is ate, the player Lose, and the opposite Win.
8. When the player in turn can not make any legal move, and his King is being attacked just now, the player Lose, and the opposite Win.
9. If both side left only King, called Draw.
Note:
WishingBone and WildLeopard are all clever enough, that they can calculate out any situation which would appear. And each of them will choose the method which benefit self best when it's his turn.
Input
Each case will first contain a char, just be 'B' or 'W', means it's Black or White's turn.
Then eight lines, and each line has eight integer, showing a 8*8 pad. 0 means no chess on the grid, 1 means the Black King, 2 means the White King, 3 means the White Rook.
There are several cases.
Output
You just need to print out the game's result of the Leopard, within 'Win', 'Lose', 'Draw', 'Forced-Draw'.
Each case take one line.
Sample Input
W 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 2 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B 1 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sample Output
Lose Draw Forced-DrawSubmit
Source: ZOJ Monthly, February 2005