P7184 [CRCI2008-2009] MAJSTOR
Background
Rock-paper-scissors is a popular two-player game.
Description
In the game, both players show one of three hand gestures: rock, paper, or scissors.
If both players show the same gesture, the game is a draw. Otherwise, scissors beats paper, paper beats rock, and rock beats scissors.
Sven has been studying the complex psychology of the game for many years and has become a true master. His friends have no chance against him in one-on-one games.
As the world championship approaches, Sven is playing the game simultaneously with $n$ friends to practice his skills.
There are $r$ rounds. In each round, Sven and each of his friends show one of the three gestures.
Scoring rules:
- If Sven wins, he gets $2$ points.
- If it is a draw, he gets $1$ point.
- If the opponent wins, he gets $0$ points.
Write a program to compute Sven's total score for his actual plays, and also the maximum possible total score if he knows all the gestures his friends will play in advance.
Input Format
The first line contains a positive integer $r$, the number of rounds.
The second line contains $r$ characters. The $i$-th character indicates Sven's gesture in round $i$, and it is one of `S` (scissors), `P` (paper), `R` (rock).
The third line contains a positive integer $n$, the number of his friends.
The next $n$ lines each contain $r$ characters. The $j$-th character indicates the gesture played by Sven's $i$-th friend in round $j$, and it is one of `S` (scissors), `P` (paper), `R` (rock).
Output Format
On the first line, output Sven's actual score.
Assuming his friends do not change their gestures, on the second line output his maximum possible score.
Explanation/Hint
#### Constraints
For $100\%$ of the testdata, $1 \le n, r \le 50$.
#### Notes
- This problem is worth $50$ points in total.
- This problem is translated from [COCI2008-2009](https://hsin.hr/coci/archive/2008_2009/) [CRCI2008-2009](https://hsin.hr/coci/archive/2008_2009/regional_tasks.pdf) MAJSTOR. Translator: @[tearing](https://www.luogu.com.cn/user/219791)。
Translated by ChatGPT 5