592A - PawnChess - CodeForces Solution


implementation *1200

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(),x.end()

#define sc(x) scanf("%d",&x)

#define sc2(x,y) scanf("%d",&x),scanf("%d",&y)

#define sc3(x,y,z) scanf("%d",&x),scanf("%d",&y),scanf("%d",&z)

#define scl(x) scanf("%lld",&x)

#define scl2(x,y) scanf("%lld",&x),scanf("%lld",&y)

#define pr(x) printf("%d\n",x)

#define prl(x) printf("%lld\n",x)

#define yes printf("Yes\n")

#define no printf ("No\n")

#define ll long long

#define pb push_back

#define F first

#define S second

#define forn() for(int i=0;i<n;i++)

#define pla_pla ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N=2e5+1;

map<char,int> mp;

ll mod=1e9+7;

int main()
{
    pla_pla
    string s[8];
    int n=8;
     forn()
            cin>>s[i];
            int mw=16,mb=16;
        for(int j=0;j<8;j++)
        for(int i=n-1;i>=0;i--)
        {
            if(s[i][j]=='W')
            {
               int l=i-1;
           while(l>=0&&s[l][j]!='B')
           {
               l--;
           }
           if(l==-1)
            { l++; mw=min(mw,i-l);}
        }
        }
        for(int j=0;j<n;j++)
            for(int i=0;i<n;i++)
        {
            if(s[i][j]=='B')
            {
                int l=i+1;
             while(l<n&&s[l][j]!='W')
           {
               l++;
           }
           if(l==n)mb=min(mb,l-1-i);
        }
        }
        if(mw<=mb)cout<<"A\n";
        else cout<<"B\n";
}


Comments

Submit
0 Comments
More Questions

979A - Pizza Pizza Pizza
731A - Night at the Museum
742A - Arpa’s hard exam and Mehrdad’s naive cheat
1492A - Three swimmers
1360E - Polygon
1517D - Explorer Space
1230B - Ania and Minimizing
1201A - Important Exam
676A - Nicholas and Permutation
431A - Black Square
474B - Worms
987B - High School Become Human
1223A - CME
1658B - Marin and Anti-coprime Permutation
14B - Young Photographer
143A - Help Vasilisa the Wise 2
320A - Magic Numbers
1658A - Marin and Photoshoot
514A - Chewbaсca and Number
382A - Ksenia and Pan Scales
734B - Anton and Digits
1080A - Petya and Origami
1642D - Repetitions Decoding
1440A - Buy the String
1658F - Juju and Binary String
478A - Initial Bet
981A - Antipalindrome
365A - Good Number
1204B - Mislove Has Lost an Array
1409D - Decrease the Sum of Digits