JOIN
Get Time

   Problem Statement  

 Problem Statement for EllysRPS

Problem Statement

    Rock-Paper-Scissors is a two-player game which is played in rounds. In each round both players simultaneously show one of three shapes with an outstretched hand. The three shapes are "rock" (a fist), "paper" (a flat hand), or "scissors" (two fingers forming the blades of a pair of scissors). Rock beats scissors (breaks it); scissors beat paper (cut it); and paper beats rock (covers it). If both players show the same shape the round is considered a tie.



There is a Rock-Paper-Scissors tournament in Elly's school. The tournament has a round-robin structure, i.e., each contestant plays a match against each other contestant. Each match between two contestants consists of K rounds. The winner of a match is the player who won more rounds. If both players have won the same number of rounds, the entire match is a tie.



Shortly before the start of the tournament, the organizers figured out that it will take quite a lot of time to complete ? there are K * N * (N - 1) / 2 rounds to be played (where N is the number of people who have signed up for the tournament). The headmaster of the school proposed to change the rules of the tournament in the following way. Each contestant will be required to come up with a fixed "strategy": a sequence of K shapes (each being rock, paper, or scissors). After that, instead of playing the rounds in person, the games will be simulated by a computer using the contestants' strategies. This means that in each of his or her matches each contestant will "show" the same K chosen shapes in the same chosen order.



Elly managed to get her hands on the strategies of all other contestants. Now she can choose her own strategy. Elly doesn't want to lose, but she also doesn't want to make enemies at school. For that reason she wants to choose a strategy that will tie each of the other contestants. The girl has asked you to help her by calculating how many different strategies with this property exist. She has given you the strategies of the other contestants in the String[] strategies. Each element will be the strategy of one of her opponents: a string of K characters specifying the shapes the contestant will play, in order, with 'R' being rock, 'P' being paper, and 'S' being scissors.



Compute and return the exact number of possible strategies for Elly, given that she wants to tie each of the other contestants.
 

Definition

    
Class:EllysRPS
Method:getCount
Parameters:String[]
Returns:long
Method signature:long getCount(String[] strategies)
(be sure your method is public)
    
 

Constraints

-strategies will contain between 1 and 100 elements, inclusive.
-Each element of strategies will contain between 1 and 20 characters, inclusive.
-All elements of strategies will have the same length.
-Each character of each element of strategies will be one of 'R', 'P', or 'S'.
 

Examples

0)
    
{"SSRRRPRRSS", "PPRRSRRRSR", "SRPRPPSRSR", "PSSRRRPRRR", "PSRPSPRSSP", "RSRSRRRPRP"}
Returns: 174
There are 6 other contestants in addition to Elly, and each match will consist of 10 rounds.
1)
    
{"R", "P", "S"}
Returns: 0
No matter which shape Elly chooses, she'll have exactly one win, one loss, and one tie.
2)
    
{"R", "R", "R"}
Returns: 1
Obviously the solution here is to also choose Rock.
3)
    
{"SRSRPSPSSPPSPR", "SRSPSSPSRRRPPR", "SRSRSSPSRPSSSS", "SSRSPPPPPPSSSS", "SSRPRSPPPPSSPP",
 "PSRSPPRRSPPSSS", "PRRRPPSRSPPSSP", "PPRRRRSRSSPPRP", "RSSRRSRPPSSRPP", "PRRRPPSRSPPSSP",
 "PRRRPPSRSPPSSP", "PSRSPPRRSPPSSS", "PRRRPPSRSPPSSP", "PSRSPPRRSPPSSS", "PSRSPPRRSPPSSS",
 "PSRSPPRRSPPSSS", "PRRRPPSRSPPSSP", "SSRPRSPPPPSSPP", "SSRPRSPPPPSSPP", "RSSRRSRPPSSRPP",
 "SRSRPSPSSPPSPR", "RSSRRSRPPSSRPP", "PSRSPPRRSPPSSS", "RSSRRSRPPSSRPP", "SSRPRSPPPPSSPP",
 "PSRSPPRRSPPSSS", "SRSRPSPSSPPSPR", "SRSRPSPSSPPSPR", "PSRSPPRRSPPSSS", "PSRSPPRRSPPSSS",
 "SSRPRSPPPPSSPP", "SRSRPSPSSPPSPR", "RSSRRSRPPSSRPP", "SRSRSSPSRPSSSS", "SSRPRSPPPPSSPP",
 "PSRSPPRRSPPSSS", "SRSRPSPSSPPSPR", "PSRSPPRRSPPSSS", "SSRPRSPPPPSSPP", "SRSRSSPSRPSSSS",
 "SRSRPSPSSPPSPR", "SRSRSSPSRPSSSS"}
Returns: 1014

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.

This problem was used for:
       2017 TCO Algorithm Round 1C - Division I, Level Three