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