|
||||||||||
King¡¯s CaseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 118 Accepted Submission(s): 10 Problem Description As you maybe know, Chess is a board game played between two players. It is played on a chessboard, which is a square-checkered board with 64 squares arranged in an eight-by-eight grid. At the start, each player controls sixteen pieces: one king, one queen, two rooks, two knights, two bishops, and eight pawns. The object of the game is to checkmate the opponent's king, whereby the king is under immediate attack (in "check") and there is no way to remove or defend it from attack on the next move. The board has eight rows (called ranks and denoted with numbers 1 to 8) and eight columns (called files and denoted with letters a to h). White always moves first. After the initial move, the players alternately move one piece at a time (with the exception of castling, when two pieces are moved). Pieces are moved to either an unoccupied square, or one occupied by an opponent's piece, capturing it and removing it from play. With the sole exception of en passant, all pieces capture opponent's pieces by moving to the square that the opponent's piece occupies. (In this problem, there will not be ¡®en passant¡¯, ¡®Castling¡¯ or ¡®Promotion¡¯. This simplifies the problem a little.) Each chess piece has its own style of moving. ¡ñ The king moves one square in any direction. The king has also a special move which is called castling and also involves a rook, but not in this problem! ¡ñ The rook can move any number of squares along any rank or file, but may not leap over other pieces. Along with the king, the rook is also involved during the king's castling move, but not in this problem! ¡ñ The bishop can move any number of squares diagonally, but may not leap over other pieces. ¡ñ The queen combines the power of the rook and bishop and can move any number of squares along rank, file, or diagonal, but it may not leap over other pieces. ¡ñ The knight moves to any of the closest squares which are not on the same rank, file or diagonal, thus the move forms an "L"-shape two squares long and one square wide. The knight is the only piece which can leap over other pieces. ¡ñ The pawn may move forward to the unoccupied square immediately in front of it on the same file, or on its first move it may advance two squares along the same file provided both squares are unoccupied, or it may move to a square occupied by an opponent¡¯s piece, which is diagonally in front of it on an adjacent file, capturing that piece. The pawn has two special moves, the en passant capture, and pawn promotion, but not in this problem! Just as you see, the white pawn move upward and the black pawn move downward. A player may not make any move which allows the King to be captured. If such a move is not possible, the game ends. The result will be a checkmate, if king is under immediate attack or stalemate, if it is not. -----Wikipedia. The question your program should answer is when a player makes a move, determine the result of the move. The result can be one of these, Checkmate! -----------------This move result a win. Draw -------------------------This move result a stalemate Check! -----------------------The game has not finished yet, but this move is a check Just a normal move --------The game has not finished yet, and this move is not a check This is not a legal move --This is happened when move a piece not belongs to it, want to eat a piece belongs to it, want to move a piece not under the style of that kind of piece, when you under check that move is not a right response or after that move you king will be capture. Input The input will consist of one or more test cases. The first line of the input will be a single integer T, indicates the number of the cases. Each test case adheres to the following format: ¡ñ On the first line there will be ¡°White makes a move¡± or ¡°Black makes a move¡±. ¡ñ On the second line have two positions indicate the move from and to. The position is such is ¡°e4¡±, in a lowercase character ¡®a¡¯ to ¡®h¡¯ and a number from 1 to 8. So the positions are always in the board. ¡ñ On the next 8 lines will represent the board before the move. ¡ñ The Black pieces will be represented by uppercase characters. K for King, Q for Queen, R for Rook, B for Bishop, N for Knight, P for Pawn. The White pieces will be represented by lowercase characters, just like the Blacks. You may assume the board before move is legal and the game have not finished yet. Squares has no piece in is represented by ¡®.¡¯. There is not white line between cases. Output Output ¡°Checkmate!¡±, ¡°Draw¡±, ¡°Check!¡±, ¡°Just a normal move¡± or ¡°This is not a legal move¡± in a line. Sample Input
Sample Output
Source | ||||||||||
|