22112_Chess

2022-5-16 18:21| 发布者: Hocassian| 查看: 25| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506118377700-Problem List-采集的数据-后羿采集器.html

Pro.ID

22112

Title

Chess

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22112

AC

0

Submit

6

Ratio

0.00%

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    Chess is a game for two players, one with the White pieces and one with the Black pieces. At the beginning of the game, the pieces are set up as pictured below. (See diagrams below to identify pieces.) These hints will help you to remember the proper board setup
    (1) Opposing Kings and Queens go directly opposite each other.
    (2) The square in the lower right hand comer is a light one.
    (3) The White Queen goes on a light square, the Black Queen on a dark square.
    White always moves first, and then the players take turns moving. Only one piece may be moved at each turn (except for castling, a special move that is explained later). The Knight is the only piece that can jump over other pieces. All other pieces move only along unblocked lines. You may not moye a piece to a square already occupied by one of your own pieces. But you can capture an enemy piece that stands on a square where one of your pieces can move. Simply remove the enemy piece from the board and put your own piece in its place.

    Figure 1
    The Pieces and How They Move
    The Queen

    The Queen is the most powerful piece. She can move any number of squares in any direction: horizontal, vertical, or diagonal - if her path is not blocked. She can reach any of the squares with dots in this diagram.


    Figure 2

    The Rook
    The Rook is the next most powerful piece. The Rook can move any number of squares vertically or horizontally if its path is not blocked.

    Figure 3
    The Bishop
    The Bishop can move any number of squares diagonally if its path is not blocked. Note that this Bishop starts on a light square and can reach only other light squares. At the beginning of the game, you have one "dark-square" Bishop and one "light-square" Bishop.

    Figure 4
    The Knight
    The Knight's move is special. It hops directly from its old square to its new square. The Knight can jump over other pieces between its old and new squares. Think of the Knight’s move as an "L." It moves two squares horizontally or vertically and then makes a right-angle turn for one more square. The Knight always lands on a square opposite in color from its old square.

    Figure 5
    The King
    The King is the most important piece. When he is trapped, his whole army loses. The King can move one square in any direction, for example, to any of the squares with dots in this diagram. (An exception is castling, which is explained later.) The King may never move into check, that is, onto a square attacked by an opponent's piece.

    Figure 6
    The Pawn
    The pawn moves straight ahead (never backward), but it captures diagonally. It moves one square at a time, but on its first move it has the option of moving forward one or two squares. In the diagram, the squares with dots indicate possible destinations for the pawns. The White pawn is on its original square, so it may move ahead either one or two squares. The Black pawn has already moved, so it may move ahead only one square at a time. The squares on which these pawns may capture are indicated by an X.

    Figure 7
    If a pawn advances all the way to the opposite end of the board, it is immediately "promoted" to another piece, usually a Queen. It may not remain a pawn or become a King. Therefore, it is possible for each player to have more than one Queen or more than two Rooks, Bishops, or Knights on the board at the same time. But I DO NOT want you to consider such situation in this problem.
    Special Moves
    Castling
    Each player may "castle" only once during a game and when conditions are met. Castling is a special move that lets a player move two pieces at once - the King and one Rook. In castling, the player moves his King two squares to its left or right toward one of his Rooks. At the same time, the Rook involved goes to the square beside the King and toward the center of the board (see illustrations at left). In order to castle, neither the King nor the Rook involved may have moved before. Also, the King may not castle out of check, into check, or through check. Further, there may not be pieces of either color between the King and the Rook involved in castling.

    Figure 8

    Castling is often a very important move because it allows you to place your King in a safe location and also allows the Rook to become more active.
    When the move is legal, each player has the choice of castling Kingside or Queenside or not at all, no matter what the other player chooses to do.
    En Passant
    This French phrase is used for a special pawn capture. It means "in passing", and it occurs when one player moves a pawn two squares forward to try to avoid capture by the opponent's pawn. The capture is made exactly as if the player had moved the pawn only one square forward.
    In the diagram, the Black pawn moves up two squares to the square with the dot. On its turn the White pawn may capture the Black one on the square marked with the X. If the White player does not exercise this option immediately - before playing some other move - the Black pawn is safe from "en passant" capture for the rest of the game. But new opportunities may arise for each pawn in similar circumstances.

    Figure 9
    For making the question simple, we assume that there are NO "En Passant" happened in the game.
    About Check and Checkmate
    The main goal of chess is to checkmate your opponent's King. The King is not actually captured and removed from the board like other pieces. But if the King is attacked ("checked") and threatened with capture, it must get out of check immediately. If there is no way to get out of check, the position is a "checkmate," and the side that is checkmated loses.
    You may not move into check. For example, moving into a direct line with your opponent's Rook, when if there are no other pieces between the Rook and your King, is not a legal move. Otherwise, the Rook could "capture" the King, which is not allowed.
    If you are in check, there are three ways of getting out:
    (1) Capturing the attacking piece;
    (2) Placing one of your own pieces between the attacker and your King (unless the attacker is a Knight);
    (3) Moving the King away from the attack.
    If a checked player can do none of these, he is checkmated and loses the game.
    If a King is not in check, but that player can make no legal move, the position is called a stalemate and the game is scored as a draw, or tie.
    How to Read and Write Chess
    There are many different ways to write chess moves. The most popular method is called algebraic notation (the method described below is not complete algebraic notation, I just made it simple). The main idea is that every square has a name like this:

    Figure 10
    It looks very complicated but it's not! Each square on a chessboard has a first name (a letter) and a last name (a number). The letter identifies a file (column) and the number identifies a rank (row). Now, the important part is to know how to identify the pieces you are moving.
    You just need to use a single capital letter:
    K = King     Q = Queen     R = Rook     B = Bishop     N = Knight
    Note that "P" is not used. Chess players have agreed that a move without a letter — such as e4 — is understood to be a pawn move. You are almost ready to start using chess notation. Just pay attention to the following symbols:
    0-0 = King-side castle
    0-0-0 = Queen-side castle
    It’s a great idea to note your games. You can analyze and learn from your mistakes. We all make a lot of mistakes when we are learning a new thing. Don’t worry! Mistakes will help you improve your chess skills. Let’s put in practice what you are learning. We will use the famous "Scholar Mate," also called the four-move checkmate.



    Figure  11
    So, I can write chess moves like this.
    7
    e4 e5 Bc4 h6 Qh5 a5 Qf7
    From this, you can know that the player with the "White" pieces won the game. Your job here is to judge the result from the given chess moves.

    输入

    The input file will consist of a series games. Each game will start with a positive integer number n in a single line, which indicates the number of moves you will get in the game description. Then you can get a move list with n moves in the following n lines, a move in a line without any redundant spaces.
    The input is terminated by a line with a single zero.

    输出

    Description
    Chess is a game for two players, one with the White pieces and one with the Black pieces. At the beginning of the game, the pieces are set up as pictured below. (See diagrams below to identify pieces.) These hints will help you to remember the proper board setup
    (1) Opposing Kings and Queens go directly opposite each other.
    (2) The square in the lower right hand comer is a light one.
    (3) The White Queen goes on a light square, the Black Queen on a dark square.
    White always moves first, and then the players take turns moving. Only one piece may be moved at each turn (except for castling, a special move that is explained later). The Knight is the only piece that can jump over other pieces. All other pieces move only along unblocked lines. You may not moye a piece to a square already occupied by one of your own pieces. But you can capture an enemy piece that stands on a square where one of your pieces can move. Simply remove the enemy piece from the board and put your own piece in its place.

    Figure 1
    The Pieces and How They Move
    The Queen

    The Queen is the most powerful piece. She can move any number of squares in any direction: horizontal, vertical, or diagonal - if her path is not blocked. She can reach any of the squares with dots in this diagram.


    Figure 2

    The Rook
    The Rook is the next most powerful piece. The Rook can move any number of squares vertically or horizontally if its path is not blocked.

    Figure 3
    The Bishop
    The Bishop can move any number of squares diagonally if its path is not blocked. Note that this Bishop starts on a light square and can reach only other light squares. At the beginning of the game, you have one "dark-square" Bishop and one "light-square" Bishop.

    Figure 4
    The Knight
    The Knight's move is special. It hops directly from its old square to its new square. The Knight can jump over other pieces between its old and new squares. Think of the Knight’s move as an "L." It moves two squares horizontally or vertically and then makes a right-angle turn for one more square. The Knight always lands on a square opposite in color from its old square.

    Figure 5
    The King
    The King is the most important piece. When he is trapped, his whole army loses. The King can move one square in any direction, for example, to any of the squares with dots in this diagram. (An exception is castling, which is explained later.) The King may never move into check, that is, onto a square attacked by an opponent's piece.

    Figure 6
    The Pawn
    The pawn moves straight ahead (never backward), but it captures diagonally. It moves one square at a time, but on its first move it has the option of moving forward one or two squares. In the diagram, the squares with dots indicate possible destinations for the pawns. The White pawn is on its original square, so it may move ahead either one or two squares. The Black pawn has already moved, so it may move ahead only one square at a time. The squares on which these pawns may capture are indicated by an X.

    Figure 7
    If a pawn advances all the way to the opposite end of the board, it is immediately "promoted" to another piece, usually a Queen. It may not remain a pawn or become a King. Therefore, it is possible for each player to have more than one Queen or more than two Rooks, Bishops, or Knights on the board at the same time. But I DO NOT want you to consider such situation in this problem.
    Special Moves
    Castling
    Each player may "castle" only once during a game and when conditions are met. Castling is a special move that lets a player move two pieces at once - the King and one Rook. In castling, the player moves his King two squares to its left or right toward one of his Rooks. At the same time, the Rook involved goes to the square beside the King and toward the center of the board (see illustrations at left). In order to castle, neither the King nor the Rook involved may have moved before. Also, the King may not castle out of check, into check, or through check. Further, there may not be pieces of either color between the King and the Rook involved in castling.

    Figure 8

    Castling is often a very important move because it allows you to place your King in a safe location and also allows the Rook to become more active.
    When the move is legal, each player has the choice of castling Kingside or Queenside or not at all, no matter what the other player chooses to do.
    En Passant
    This French phrase is used for a special pawn capture. It means "in passing", and it occurs when one player moves a pawn two squares forward to try to avoid capture by the opponent's pawn. The capture is made exactly as if the player had moved the pawn only one square forward.
    In the diagram, the Black pawn moves up two squares to the square with the dot. On its turn the White pawn may capture the Black one on the square marked with the X. If the White player does not exercise this option immediately - before playing some other move - the Black pawn is safe from "en passant" capture for the rest of the game. But new opportunities may arise for each pawn in similar circumstances.

    Figure 9
    For making the question simple, we assume that there are NO "En Passant" happened in the game.
    About Check and Checkmate
    The main goal of chess is to checkmate your opponent's King. The King is not actually captured and removed from the board like other pieces. But if the King is attacked ("checked") and threatened with capture, it must get out of check immediately. If there is no way to get out of check, the position is a "checkmate," and the side that is checkmated loses.
    You may not move into check. For example, moving into a direct line with your opponent's Rook, when if there are no other pieces between the Rook and your King, is not a legal move. Otherwise, the Rook could "capture" the King, which is not allowed.
    If you are in check, there are three ways of getting out:
    (1) Capturing the attacking piece;
    (2) Placing one of your own pieces between the attacker and your King (unless the attacker is a Knight);
    (3) Moving the King away from the attack.
    If a checked player can do none of these, he is checkmated and loses the game.
    If a King is not in check, but that player can make no legal move, the position is called a stalemate and the game is scored as a draw, or tie.
    How to Read and Write Chess
    There are many different ways to write chess moves. The most popular method is called algebraic notation (the method described below is not complete algebraic notation, I just made it simple). The main idea is that every square has a name like this:

    Figure 10
    It looks very complicated but it's not! Each square on a chessboard has a first name (a letter) and a last name (a number). The letter identifies a file (column) and the number identifies a rank (row). Now, the important part is to know how to identify the pieces you are moving.
    You just need to use a single capital letter:
    K = King     Q = Queen     R = Rook     B = Bishop     N = Knight
    Note that "P" is not used. Chess players have agreed that a move without a letter — such as e4 — is understood to be a pawn move. You are almost ready to start using chess notation. Just pay attention to the following symbols:
    0-0 = King-side castle
    0-0-0 = Queen-side castle
    It’s a great idea to note your games. You can analyze and learn from your mistakes. We all make a lot of mistakes when we are learning a new thing. Don’t worry! Mistakes will help you improve your chess skills. Let’s put in practice what you are learning. We will use the famous "Scholar Mate," also called the four-move checkmate.



    Figure  11
    So, I can write chess moves like this.
    7
    e4 e5 Bc4 h6 Qh5 a5 Qf7
    From this, you can know that the player with the "White" pieces won the game. Your job here is to judge the result from the given chess moves.
    Input
    The input file will consist of a series games. Each game will start with a positive integer number n in a single line, which indicates the number of moves you will get in the game description. Then you can get a move list with n moves in the following n lines, a move in a line without any redundant spaces.
    The input is terminated by a line with a single zero.
    Output
    For each game, you are supposed to give a judgment in a single line. The judgment should be one of the following statements.
    No. Statement             Remark
    1 White Win          The play with the "White" pieces wins the game at the end of game
    2 Black Win              The play with the "Black" pieces wins the game at the end of game
    3 Stalemate              You can find the details about stalemate in the problem description
    4 Draw                        No one won the game, and no stalemate happened.
    5 Dead Moves          After one play won the game or stalemate happened, there still are moves in the list
    6 Puzzle Move          From the move you get, you can’t decide which chess should be moved
    7 Illegal Move          Some move is illegal
    If the game ended normally, you will get a statement between No.1 and No.4. If the game didn’t end normally, and there are not puzzle moves and illegal moves before where it should end, you will get a statement of No.5. Otherwise, output statement of No.6 or No.7 base on which you find first.
    Sample Input
    7
    e4
    e5
    Bc4
    h6
    Qh5
    a5
    Qf7
    0
    Sample Output
    White Win
    Source

    样例输入

    7
    e4
    e5
    Bc4
    h6
    Qh5
    a5
    Qf7
    0

    样例输出

    White Win

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部