Monday, November 24, 2014

12750 - Keep Rafa at Chelsea

12750 - Keep Rafa at Chelsea

The eccentric owner of Chelsea Football Club Mr. Billionaire has sacked his Manager once again and
appointed only the 10th manager in his prolonged 9 years' reign at the club. And to the delight of the
rival Manchester United fan's, it's none other than the great entertainer named Rafa Benitez! (If you
follow EPL, you must know what I mean. If you don't, you can still solve the problem but you are
missing the next best thing after Monty Python and Mr. Bean.) Rafa, obviously with his unquestionable
talent as a football manager, has immediately lead his team to a nosedive in performance and the poor
United fans are worried that dear Mr. Billionaire might put an end to all the fun and sack Rafa sooner
than any rival fan can hope for. So they decide to start an extensive \Keep Rafa at Chelsea" campaign.
And you are the score keeper of the campaign.
You are given a series of match results for Chelsea denoted by `W' (win), `L' (Lose) or `D' (Draw). If
Chelsea do not win a game for 3 consecutive matches, Rafa will be sacked instantly and start playing
this game (www.mousebreaker.com/games/romanswrath/playgame). Your job is to gure out how
many games will dear Rafa last at Chelsea.
Input
The input begins with a number T (1 T 100), the number of test cases. Each of the following lines
contains a case. A case begins with n (3 n 500), the number of games in the input. Each of the
following n lines contains a single letter among `W', `L' or `D'. These are the results from rst n games
of Chelsea (in chronological order) under Benitez.
Output
For each test case produce a line of the form `Case X: Y '. X is the serial number of the test case
while Y is the number of games Rafa can keep his job in this particular case. If Rafa doesn't lose his
job after all the games in a case, print `Yay! Mighty Rafa persists!'
Sample Input
3
5
L
D
L
D
W
6
L
D
W
L
L
L
3
D
D
W
Sample Output
Case 1: 3
Case 2: 6
Case 3: Yay! Mighty Rafa persists!

 

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int n,T,d=1,i;
    char C[505];
    scanf("%d",&n);
    while(n>0)
    {
         scanf("%d",&T);
         int c=0,count=0;
        for(i=0;i<T;i++)
        {
            cin>>C[i];
        }
 
        for(i=0;i<T;i++)
        {
            if(C[i]=='L'||C[i]=='D')
            {
                count ++;
                c++;
                if(count ==3)
                break;
            }
            else
            {   c++;
                count=0;
            }
        }
        if(count>=3)
        printf("Case %d: %d\n",d,c);
        else
         printf("Case %d: Yay! Mighty Rafa persists!\n",d,c);
 
        n--;
        d++;
    }
return 0;
}

 


 


 


12750 - Keep Rafa at Chelsea uva link

No comments:

Post a Comment