Uva 12700 Banglawash Solution

Problem Link   
Uva 12700    Banglawash Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,j=1;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int w=0,b=0,d=0,a=0;
        char m[n+1];
        for(int i=0; i<n; i++)
            cin>>m[i];

        for(int i=0; i<n; i++)
        {
            switch(m[i])
            {
               case 'W':
                   w++;
                   break;
               case 'B':
                    b++;
                    break;
               case 'T':
                    d++;
                    break;
               case 'A':
                    a++;
                    break;
            }
        }
        if(w==0 && b>0 && d==0)
            cout<<"Case "<<j<<": BANGLAWASH"<<endl;
        else if(b==0 && w>0 && d==0)
            cout<<"Case "<<j<<": WHITEWASH"<<endl;
        else if(a==n)
            cout<<"Case "<<j<<": ABANDONED"<<endl;
        else if(b>w)
            cout<<"Case "<<j<<": BANGLADESH "<<b<<" - "<<w<<endl;
        else if(w>b)
            cout<<"Case "<<j<<": WWW "<<w<<" - "<<b<<endl;
        else if(b==w)
            cout<<"Case "<<j<<": DRAW "<<b<<" "<<d<<endl;
        j++;
    }
    return 0;
}

No comments

Theme images by enjoynz. Powered by Blogger.