HDU 2357 8 Ball wins

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=2537
Tip: Just look for ' B ' and ' L ' when it's time to see who wins.

Problem Description

8 Ball is a game of billiards rules. The table has 7 red balls, 7 yellow ball and a black ball, and of course a white ball. For the subject, we use the following simplification rules: Red, yellow two players take turns with the white ball to hit their own color of the ball, if the color of the 7 balls in all, then the player can play black ball, if the hit in the count he wins. If you put the black ball in before hitting all the balls in your own color, you lose. If the player accidentally hits the opponent's ball, the ball will still be in effect.
Now give the order of the ball (except the white ball), and the black ball by which side, your task is to determine which side is the winner.
Suppose there is not a single shot in a black ball and other colored balls.

Input

The input contains multiple sets of data. The first row of each set of data is an integer N (1<=n<=15), which indicates the number of balls scored and the n=0 indicates the end. Then there is a row that contains n characters, which in turn indicates which ball is being scored. If it's ' B ', it means the black ball that red is hitting, and if it's ' L ', it's the black ball that Huangfang hit. If ' Y ' means yellow ball, ' R ' denotes red ball. There are no spaces between characters.
All inputs meet the following criteria: When the last ball hits the game is over, and the red and black balls are no more than 7.

Output

For each set of data, output one line. If the red side wins, output ' red '; Huangfang wins, output ' Yellow '.

Sample Input

5
Ryrrb
9
Rrrryrrrb
0

Sample Output

Yellow
Red

#include <iostream>#include <cstdio>#include <cstring>using namespace STD;Chars[ -];intMain () {intM while(Cin&GT;&GT;M,M) {Cin>>s;intSumr=0, sumy=0;intLen =strlen(s); for(intI=0; i<len; i++) {if(S[i] = =' R ') sumr++;if(S[i] = =' Y ') sumy++;if(sumy==7&& s[i]==' L ')            {puts("Yellow");//cout<<666;                 Break; }Else if(sumr==7&& s[i]==' B ')            {puts("Red"); Break; }if(sumr!=7&& s[i]==' B ')            {puts("Yellow");//cout<<666;                 Break; }Else if(sumy!=7&& s[i]==' L ')            {puts("Red"); Break; }        }    }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 2357 8 Ball wins

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.