Thursday, March 23, 2017

uva problem-12700 Banglawash

problem link:
In this you just you have to simply count win loss tie and draw then just establish a simple logic

#include<stdio.h>
int  main()
{
    int m,n,i,j,b,w,t,a;
    char ch[100];
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&n);
       scanf("%s",ch);
       b=0;w=0;t=0;a=0;
        for(j=0;j<n;j++)
        {
            if(ch[j]=='B')
                b++;
            else if
                (ch[j]=='W')
                w++;
            else if(ch[j]=='T')
            t++;
            else if(ch[j]='A')
                a++;
        }
        if(b>0&&w==0&&t==0)
            printf("Case %d: BANGLAWASH\n",i);
        else if(b==0&&w>0&&t==0)
            printf("Case %d: WHITEWASH\n",i);
        else if(t==n||(b!=0&&w!=0&&b==w)||(n>a>0&&t==n-a/2||(b==0&&w==0&&t!=0)))
            printf("Case %d: DRAW %d %d\n",i,b,t);
        else if(b==0&&w==0&&t==0&&a==n)
            printf("Case %d: ABANDONED\n",i);
        else if(b<w)
            printf("Case %d: WWW %d - %d\n",i,w,b);
        else if(w<b)
            printf("Case %d: BANGLADESH %d - %d\n",i,b,w);
    }
    return 0;
}

No comments:

Post a Comment