Black and White Cells - BWCELL CodeChef Easy Question

Welcome back to the world of solution !
Today's question is Black and White Cells .

Here is a link to the PROBLEM

This question is similar to the game of chomp's end situation if you have read about it .

So the winning trick for a player in this game is to keep the the number of cells on each side equal for the other player and hence whatever the other player moves , copy it and in the end he will be forced to choose the white cell.

So aleksa will win if there are unequal cells in the beginning and Chef will win if there are equal cells in the beginning.
We just need to check this.

This C++ program will help you understand it better .

Code :-

#include <iostream>
using namespace std;

int main() {
    int t;
    scanf("%d",&t);
    while(t--)
    {
        char s[10002];
        cin>>s;
       // cout<<s;
        int b1=0,b2=0;
        int i=0;
        while(s[i]!='W')
        {
            b1++;
            i++;
        }
        i++;
        while(s[i]!='\0')
        {
          b2++;
          i++;  
        }
        //cout<<"b1 :"<<b1<<" b2 : "<<b2<<"  ";
        if(b1==b2)
        {
            cout<<"Chef"<<endl;
        }
        else
        {
            cout<<"Aleksa"<<endl;
        }
    }
// your code goes here
return 0;
}


Please leave any doubts and queries in the comments section .

Comments

Popular Posts