随笔—邀请赛前训—Codeforces Round #328 (Div. 2) A. PawnChess

题意:给你一个8×8的棋盘分布,红黑棋子,双方只能朝上下其中一个方向移动,不可跨越对方或自己的棋子,最先到对面底部的人赢。问谁赢?

思路:上下2排同时开始扫,先扫到谁都棋,谁就赢(前提是没有对方的人挡路。。)

#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

#define  MAX(x,y) (((x)>(y)) ? (x) : (y))
#define  MIN(x,y) (((x) < (y)) ? (x) : (y))
#define ABS(x) ((x)>0?(x):-(x))

const int inf = 0x7fffffff;

int occupied_by_black[10];
int occupied_by_white[10];
char mp[10][10];

int main()
{
    char winer=‘*‘;
    for(int i=1; i<=8; i++){
        scanf("%s",mp[i]+1);
    }
    for(int i=1; i<=8; i++){
        int p_for_white=i;
        int p_for_black=8-i+1;
        for(int j=1;j<=8;j++){
            if(mp[p_for_white][j] == ‘B‘)
                occupied_by_black[j]=1;
            if(mp[p_for_white][j] == ‘W‘ && occupied_by_black [j] == 0){
                occupied_by_white[j]=1;
                winer=‘A‘;
                    break;
            }
        }
        if(winer != ‘*‘)
            break;
        for(int j=1; j<=8; j++){
            if(mp[p_for_black][j] == ‘W‘)
                occupied_by_white[j]=1;
            if(mp[p_for_black][j] == ‘B‘ && occupied_by_white [j] == 0){
                occupied_by_black[j]=1;
                winer=‘B‘;
                break;

            }
        }
        if(winer != ‘*‘)
            break;
    }
    cout<<winer<<endl;
    return 0;
}
时间: 2024-08-28 00:01:14

随笔—邀请赛前训—Codeforces Round #328 (Div. 2) A. PawnChess的相关文章

随笔—邀请赛前训—Codeforces Round #327 (Div. 2) Rebranding

题意:一个字符串,做n次变换,每次变换是把a字符与b字符全部调换.求全部调换完成后的字符串. 这道题目我一开始理解错意思了,理解成将所有a字符变成b字符,我觉得这样出貌似还更有挑战性一点..口亨 #include<cstdio> #include<cstring> #include<map> #include<iostream> using namespace std; #define MAX(x,y) (((x)>(y)) ? (x) : (y))

随笔—邀请赛前训— Codeforces Round #330 (Div. 2) Vitaly and Night

题意:给你很多对数,要么是0要么是1.不全0则ans++. 思路即题意. #include<cstdio> #include<cstring> #include<iostream> using namespace std; #define MAX(x,y) (((x)>(y)) ? (x) : (y)) #define MIN(x,y) (((x) < (y)) ? (x) : (y)) #define ABS(x) ((x)>0?(x):-(x))

随笔—邀请赛前训— Codeforces Round #330 (Div. 2) B题

题意: 这道英文题的题意稍稍有点复杂. 找长度为n的数字序列有多少种.这个序列可以分为n/k段,每段k个数字.k个数可以变成一个十进制的数Xi.要求对这每n/k个数,剔除Xi可被ai整除的情况,剔除X的第一个数(包括前导0)是bi的情况.问剩下的组合有多少种. 思路: 这题我是一波三折的.首先也没有考虑很多,看着可以暴力模拟过程,我就直接开始敲了,几个for循环敲出来,再把bug调一调和特殊情况考虑考虑,交了之后开始TLE,这时候意识到复杂度太大了,于是开始优化,做了(b[i])*(mmax/1

随笔—邀请赛前练— Codeforces Round #329 (Div. 2) 2Char

题意:给你多个字符串,只保留2及2个以内的字符,丢弃多余的字符串,问你最后留下的字符串最长能有多长? 思路: 1. 对每个字符串处理出  process[fir][sec]  只包含fir字符和sec字符 当前的最大长度.当然,超过2个字符的字符串自动跳过. 2. 注意合并 process[fir][sec].process[sec][fir].process[fir][0].process[sec][0] 3. 合并的过程还要注意特殊情况 process[fir][0] + process[s

随笔—邀请赛前训—Wizards&#39; Duel

题意:给出一个距离,2端2个物体,给出速度v1,v2   相对前进,相遇后速度不变反弹,回端点都又速度不变反弹,求第二次相遇点位置. 思路:物理常识啊... #include<cstdio> #include<cstring> #include<iostream> using namespace std; #define MAX(x,y) (((x)>(y)) ? (x) : (y)) #define MIN(x,y) (((x) < (y)) ? (x)

Codeforces Round #328 (Div. 2) B

Description Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel. Ari draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then

Codeforces Round #328 (Div. 2) A

Description 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 som

Codeforces Round #328 (Div. 2)

A. PawnChess 很简单的暴力. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<list> #include<deque> #include&l

随笔—邀请赛前练—CodeForces 588B

题意:给一个数,求最大的一个因子,这个因子还要满足不能有平方数是他的因子. 我的解法几乎是暴力的,应该可以用数学的方法不暴力(或者说不那么“暴力”)求出来. 我的解法是: #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cmath> #include<set> using namespace std; #define