题目描述
Problem Background
Rock-Paper-Scissors is a popular two-player game.
Problem Description
In the game, both players show one of three gestures with their hands: rock, paper, or scissors.
If both players show the same gesture, the game is a draw. Otherwise, scissors beat paper, paper beats rock, and rock beats scissors.
Sven has been studying the psychological intricacies of the game for years and has become a true master, with his friends having no chance against him in one-on-one games.
As the world championship approaches, Sven is playing against $n$ friends simultaneously to practice his skills.
The game consists of $r$ rounds, and in each round, Sven and each of his friends show one of the three gestures.
Scoring rules:
- Sven wins, he gets $2$ points.
- It's a draw, he gets $1$ point.
- His opponent wins, he gets $0$ points.
Write a program to calculate Sven's total score, and also his maximum possible score if he knew all the gestures his friends would show 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 represents Sven's gesture in the $i$-th round, which can only be S (scissors), P (paper), or 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 represents the gesture of Sven's $i$-th friend in the $j$-th round, which can only be S (scissors), P (paper), or R (rock).
Output Format
The first line should output Sven's actual score.
Assuming his friends do not change their gestures, the second line should output his maximum possible score.
Sample Input and Output
Sample Input #1
5
SSPPR
1
SSPPR
Sample Output #1
5
10
Sample Input #2
5
SSPPR
2
PPRRS
RRSSP
Sample Output #2
10
15
Sample Input #3
4
SPRS
4
RPRP
SRRR
SSPR
PSPS
Sample Output #3
12
21
Notes
Data Size and Constraints
For $100\%$ of the data, $1 \le n, r \le 50$.
Notes
- This problem is worth $50$ points.
- This problem is translated from COCI2008-2009 CRCI2008-2009 MAJSTOR, translated by @tearing.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分