Codeforces 592 A. PawnChess 【Codeforces Round #328 (Div. 2)】
点击打开链接
1 second
256 megabytes
standard input
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.
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.
........ ........ .B....B. ....W... ........ ..W..... ........ ........
A
..B..... ..W..... ......B. ........ .....W.. ......B. ........ ........
B
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)】相关推荐
- 【Codeforces Round #767 (Div. 2)】 C. Meximum Array 题解
[Codeforces Round #767 (Div. 2) ]C. Meximum Array 题解 1629C: Meximum Array 题解 [Codeforces Round #767 ...
- C1. Make Nonzero Sum (easy version)【Codeforces Round #829 (Div. 2】
Codeforces Round #829 (Div. 2)中C1题目 Codeforces比赛记录 文章目录 题目链接: 一.C1. Make Nonzero Sum (easy version) ...
- 【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 ...
- Codeforces Round #328 (Div. 2) 592 B. The Monster and the Squirrel
题意:Ari 每天起床的第一件事就是喂松鼠-然后他在他家的地板上画了一个正n边形(真闲-. 然后顺时针标号从1~n 然后从1开始向除了1以外的所有顶点连边 然后从2开始向除了2以外的所有顶点连边,但是 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【Codeforces Round #547 (Div. 3)】 A B C D E F1 F2 G
A 题意 问你从一个n 到 m 经过多少次数 *2 *3能到m 所以特判一下m能否整除n 然后除了以后根据奇偶去判断求次数 #include <cstdio> #include < ...
最新文章
- 网上银行跨行转账收费最高相差25倍 省钱有窍门
- ios swift ios8 模糊
- c++中实现域内,左,右对齐的方法
- Jenkins命令可视化
- Android开发笔记(七十三)代码混淆与反破解
- 有关语音识别技术的一些信息点
- Kubernetes网络策略,这一篇就够了
- 牛客网月赛24--ABC
- linux内核源码目录结构
- 外螺纹对照表_常用螺纹规范对照表
- 使用 Tesseract 进行文字识别
- php 8bit 10bit 解码,求助:我想把10bit的MKV压制成8bitMP4
- cid unmatched [object Object] at view.umd.min.js:1 TypeError: Invalid attempt to destructure non-ite
- 如何在 Excel VBA 中插入行
- python corrupt extra field_英语专四dictation模拟练习-沪江英语
- PCA 降维 + 基于轮廓系数确定K-Means最优簇数
- 睡眠键重启计算机,Windows10进入睡眠模式后按任意键会自动重启怎么办
- 阿里云OSS文件上传下载工具类
- python 计算两个经纬度的距离_python 通过两个点的经纬度计算距离
- 23rwefwgbgfdg