Codeforces Round #328 (Div. 2)Problem A. PawnChess(模拟)
来源:互联网 发布:c语言编程输出菱形 编辑:程序博客网 时间:2024/05/02 04:23
题目连接
题意:一个8*8的棋盘,A,B两个人下棋,每次是A先手,A希望最早把W移到第一排,B希望能最早把B移到最后一行,每次只能移动一步,且只能移到空的位置,问谁赢。
解法:直接模拟
#include<bits/stdc++.h>using namespace std;#define LL long long#define pb push_back#define P pair<int,int>#define cl(a,b) memset(a,b,sizeof(a))const int maxn=10005;const int inf=1<<27;char mp[10][10];int up(int i,int j){ int cnt=1; while(i>=0&&mp[i][j]=='.')i--,cnt++; if(i>=0)return inf; return cnt;}int down(int i,int j){ int cnt=1; while(i<8&&mp[i][j]=='.')i++,cnt++; if(i<8)return inf; return cnt;}int main(){ int A=inf,B=inf; for(int i=0;i<8;i++){ scanf("%s",mp[i]); } for(int i=0;i<8;i++){ for(int j=0;j<8;j++){ if(mp[i][j]=='W'){ A=min(A,up(i-1,j)); } if(mp[i][j]=='B'){ B=min(B,down(i+1,j)); } } } //cout<<A<<' '<<B<<endl; if(A<=B){ puts("A"); } else { puts("B"); } return 0;}
0 0
- Codeforces Round #328 (Div. 2)Problem A. PawnChess(模拟)
- Codeforces Round #328 (Div. 2) A PawnChess
- Codeforces Round #328 (Div. 2)A. PawnChess
- Codeforces Round #328 (Div. 2) A. PawnChess
- Codeforces Round #328 (Div. 2) A. PawnChess
- Codeforces Round #328 (Div. 2)A. PawnChess
- PawnChess (Codeforces Round #328 (Div. 2) )
- Codeforces 592 A. PawnChess 【Codeforces Round #328 (Div. 2)】
- Codeforces Round #328 (Div. 2) 592A PawnChess
- Codeforces Round #328 (Div. 2)_A. PawnChess
- 【Codeforces Round 328 (Div 2)A】【水题】PawnChess 棋子向上向下走
- Codeforces Round #346 (Div. 2) -A. Round House(模拟)
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #324 (Div. 2) PROBLEM A
- Codeforces Round #363 (Div. 2), problem: (A)
- Codeforces Round #401 (Div. 2), problem: (A)
- cf 328 div 2 A. PawnChess
- Codeforces Round #221 (Div. 2) (Problem 376A~C)
- Codeforces Round #328 (Div. 2) C ,D
- Angular(一)入门环境配置web-server.js出错解决
- CopyOnWrite 浅层次总结
- 由于ADT版本问题,若打开layout时 如果提示:Incorrect line ending: found carriage return (\r) without corresponding ne
- 第八周实践项目4--字符串加密
- Codeforces Round #328 (Div. 2)Problem A. PawnChess(模拟)
- 调试排查问题相关
- BestCoder Round #61 (div.2)
- soft lookup原因
- iOS自定义转场动画(3)——自定义模态跳转之Present
- 改造二叉树
- [软考]之软件过程模型II
- shell 中的括号——() [] {} 使用
- Tomcat下一键部署Web项目