303039: CF592A. PawnChess
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
PawnChess
题意翻译
- 输入一个 $8 \times 8$ 的棋盘,代表棋盘的布局。 - 选手 $A$ 执白棋,选手 $B$ 执黑棋,且白棋先手。黑方向棋盘下方(第八行) 行棋,白方向棋盘上方(第一行)行棋,先行棋至自己目标行的一方胜利 - 约定以 `W` 代表白棋,以 `B` 代表黑棋,只有当自己棋子向目标方向的前一格位置上没有棋子时才能行棋。 - 若选手 $A$ 胜利则输出 $A$,反之则输出 $B$。 - 数据保证不会出现堵死的情况,即一定有赢家。题目描述
Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess». This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed is not necessarily equal to the number of white pawns placed. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF592A/9900e176569f519565c0c8328f093726ce1eb9d2.png)Lets enumerate rows and columns with integers from 1 to 8. Rows are numbered from top to bottom, while columns are numbered from left to right. Now we denote as $ (r,c) $ the cell located at the row $ r $ and at the column $ c $ . There are always two players A and B playing the game. Player A plays with white pawns, while player B plays with black ones. The goal of player A is to put any of his pawns to the row $ 1 $ , while player B tries to put any of his pawns to the row $ 8 $ . As soon as any of the players completes his goal the game finishes immediately and the succeeded player is declared a winner. Player A moves first and then they alternate turns. On his move player A must choose exactly one white pawn and move it one step upward and player B (at his turn) must choose exactly one black pawn and move it one step down. Any move is possible only if the targeted cell is empty. It's guaranteed that for any scenario of the game there will always be at least one move available for any of the players. Moving upward means that the pawn located in $ (r,c) $ will go to the cell $ (r-1,c) $ , while moving down means the pawn located in $ (r,c) $ will go to the cell $ (r+1,c) $ . Again, the corresponding cell must be empty, i.e. not occupied by any other pawn of any color. Given the initial disposition of the board, determine who wins the game if both players play optimally. Note that there will always be a winner due to the restriction that for any game scenario both players will have some moves available.输入输出格式
输入格式
The input consists of the board description given in eight lines, each line contains eight characters. Character 'B' is used to denote a black pawn, and character 'W' represents a white pawn. Empty cell is marked with '.'. It's guaranteed that there will not be white pawns on the first row neither black pawns on the last row.
输出格式
Print 'A' if player A wins the game on the given board, and 'B' if player B will claim the victory. Again, it's guaranteed that there will always be a winner on the given board.
输入输出样例
输入样例 #1
........
........
.B....B.
....W...
........
..W.....
........
........
输出样例 #1
A
输入样例 #2
..B.....
..W.....
......B.
........
.....W..
......B.
........
........
输出样例 #2
B