#P7184. [CRCI2008-2009] MAJSTOR
[CRCI2008-2009] MAJSTOR
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 friends to practice his skills.
There are rounds. In each round, Sven and each of his friends show one of the three gestures.
Scoring rules:
- If Sven wins, he gets points.
- If it is a draw, he gets point.
- If the opponent wins, he gets 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 , the number of rounds.
The second line contains characters. The -th character indicates Sven's gesture in round , and it is one of S (scissors), P (paper), R (rock).
The third line contains a positive integer , the number of his friends.
The next lines each contain characters. The -th character indicates the gesture played by Sven's -th friend in round , 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.
5
SSPPR
1
SSPPR
5
10
5
SSPPR
2
PPRRS
RRSSP
10
15
4
SPRS
4
RPRP
SRRR
SSPR
PSPS
12
21
Hint
Constraints
For of the testdata, .
Notes
- This problem is worth points in total.
- This problem is translated from COCI2008-2009 CRCI2008-2009 MAJSTOR. Translator: https://www.luogu.com.cn/user/219791
Translated by ChatGPT 5
京公网安备 11011102002149号