点击打开链接

A. PawnChess
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

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.

Input

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.

Output

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.

Sample test(s)
input
........
........
.B....B.
....W...
........
..W.....
........
........

output
A

input
..B.....
..W.....
......B.
........
.....W..
......B.
........
........

output
B

Note

In the first sample player A is able to complete his goal in 3 steps by always moving a pawn initially located at (4, 5). Player B needs at least 5 steps for any of his pawns to reach the row 8. Hence, player A will be the winner.

题目大意:

有一个 8*8 的矩阵(棋盘),有 B 和 W ,B表示黑棋,W表示白棋,然后又两个人A和B,A拿白棋先走,

A想走到第一行,B想走到第八行,看谁先到达。。。

解题思路:

就是比较一下大小,需要注意的是如果B和W在同一列,而且B在W上面就直接跳过。。。

上代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;#define MM(a) memset(a,0,sizeof(a))typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 15;
const int mod = 1000000007;
const double eps = 1e10-7;
char mat[8][8];
int main()
{for(int i=0; i<8; i++)cin>>mat[i];int Mina = 999999, Minb = 999999;for(int i=0; i<8; i++){for(int j=0; j<8; j++){if(mat[j][i] == 'B')break;if(mat[j][i]=='W'){Mina = min(Mina, j);break;}}}for(int i=0; i<8; i++){for(int j=7; j>=0; j--){if(mat[j][i] == 'W')break;if(mat[j][i] == 'B'){Minb = min(Minb, 8-j);break;}}}if(Mina < Minb)puts("A");elseputs("B");return 0;
}

Codeforces 592 A. PawnChess 【Codeforces Round #328 (Div. 2)】相关推荐

  1. 【Codeforces Round #767 (Div. 2)】 C. Meximum Array 题解

    [Codeforces Round #767 (Div. 2) ]C. Meximum Array 题解 1629C: Meximum Array 题解 [Codeforces Round #767 ...

  2. C1. Make Nonzero Sum (easy version)【Codeforces Round #829 (Div. 2】

    Codeforces Round #829 (Div. 2)中C1题目 Codeforces比赛记录 文章目录 题目链接: 一.C1. Make Nonzero Sum (easy version) ...

  3. 【Christmas Game】【CodeCraft-21 and Codeforces Round #711 (Div. 2)】【Nim-博弈】【树形DP】【拆分树】

    CodeCraft-21 and Codeforces Round #711 (Div. 2) Christmas Game Nim-博弈 树形DP 拆分树 牛客链接 https://ac.nowco ...

  4. Codeforces Round #328 (Div. 2) 592 B. The Monster and the Squirrel

    题意:Ari 每天起床的第一件事就是喂松鼠-然后他在他家的地板上画了一个正n边形(真闲-. 然后顺时针标号从1~n 然后从1开始向除了1以外的所有顶点连边 然后从2开始向除了2以外的所有顶点连边,但是 ...

  5. 【Codeforces Round #784 (Div. 4)】【AK题解】

    2022年4月30日19:43:21 文章目录 2022年4月30日19:43:21 A. Division? 题目描述 测试样例 题解 B. Triple 题目描述 测试样例 题解 C. Odd/E ...

  6. 【Codeforces Round #548(Div. 2)】Edgy Trees(数学+bfs求连通块)

    题目链接 C. Edgy Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. 【Codeforces Round#618 (Div. 2)】C. Anu Has a Function 题解

    题目链接:C. Anu Has a Function 题目 Anu has created her own function f: f(x,y)=(x|y)−y where | denotes the ...

  8. 【Codeforces Round #525(Div. 2)】Ehab and another another xor problem(思维+异或)

    题目链接 D. Ehab and another another xor problem time limit per test 1 second memory limit per test 256 ...

  9. 【Codeforces Round #560 (Div. 3)】 A B C D E F1 F2

    cf560 A 题意 给你一个 2e5的01串 和 x y要求这个串%10^x = 10 ^ y 那么按照题意模拟 都变成0 那位变成1 即可 /*if you can't see the repay ...

  10. 【Codeforces Round #547 (Div. 3)】 A B C D E F1 F2 G

    A 题意 问你从一个n 到 m 经过多少次数 *2 *3能到m 所以特判一下m能否整除n  然后除了以后根据奇偶去判断求次数 #include <cstdio> #include < ...

最新文章

  1. 网上银行跨行转账收费最高相差25倍 省钱有窍门
  2. ios swift ios8 模糊
  3. c++中实现域内,左,右对齐的方法
  4. Jenkins命令可视化
  5. Android开发笔记(七十三)代码混淆与反破解
  6. 有关语音识别技术的一些信息点
  7. Kubernetes网络策略,这一篇就够了
  8. 牛客网月赛24--ABC
  9. linux内核源码目录结构
  10. 外螺纹对照表_常用螺纹规范对照表
  11. 使用 Tesseract 进行文字识别
  12. php 8bit 10bit 解码,求助:我想把10bit的MKV压制成8bitMP4
  13. cid unmatched [object Object] at view.umd.min.js:1 TypeError: Invalid attempt to destructure non-ite
  14. 如何在 Excel VBA 中插入行
  15. python corrupt extra field_英语专四dictation模拟练习-沪江英语
  16. PCA 降维 + 基于轮廓系数确定K-Means最优簇数
  17. 睡眠键重启计算机,Windows10进入睡眠模式后按任意键会自动重启怎么办
  18. 阿里云OSS文件上传下载工具类
  19. python 计算两个经纬度的距离_python 通过两个点的经纬度计算距离
  20. 23rwefwgbgfdg

热门文章

  1. Share Creators公开课:游戏美术如何提升出海游戏转化
  2. 同步电机是如何达到同步的?工作原理是什么?
  3. Myeclipse项目内容没有报错但是项目上面却有红色叉叉
  4. 陕西省本级城镇企业退休人员 - 人脸识别APP资格认证操作指南
  5. 开发QQ桌球瞄准器(5):使用注册表保存配置
  6. 从“NVIDIA禁令”看如何正确选择NVIDIA GPU卡
  7. 如何做专利挖掘,关键是寻找专利点,其实并不太难
  8. PS把模糊的照片变清晰
  9. 计算机应用基础都学什么,计算机应用基础学习计划
  10. 我的求学十年(00至10):从中学到大学,年少轻狂立大志