Essays-Pre-invitational training-codeforces Round #328 (Div. 2) A. pawnchess

Source: Internet
Author: User

Test instructions: give you an 8x8 checkerboard distribution, red and black pieces, both sides can only move up and down One direction, not to cross each other or their own pieces, the first to the opposite bottom of the people to win. Ask who wins?

Idea: Up and down 2 rows at the same time start sweep, first sweep to who all chess, who will win (premise is not the other person in the way. )

#include <cstdio>#include<cstring>#include<iostream>using namespacestd;#defineMAX (x, Y) (((x) > (y))? (x): (y))#defineMIN (x, Y) ((() < (y))? (x): (y))#defineABS (x) ((x) >0? ( x):-(x))Const intINF =0x7fffffff;intoccupied_by_black[Ten];intoccupied_by_white[Ten];Charmp[Ten][Ten];intMain () {CharWiner='*';  for(intI=1; i<=8; i++) {scanf ("%s", mp[i]+1); }     for(intI=1; i<=8; i++){        intP_for_white=i; intp_for_black=8-i+1;  for(intj=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(intj=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;}

Essays-Pre-invitational training-codeforces Round #328 (Div. 2) A. pawnchess

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.