#ABC149D. Prediction and Restriction
Prediction and Restriction
题目描述
At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:
- The player plays rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)
- Each time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):
- points for winning with Rock;
- points for winning with Scissors;
- points for winning with Paper.
- However, in the -th round, the player cannot use the hand he/she used in the -th round. (In the first rounds, the player can use any hand.)
Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.
The information Takahashi obtained is given as a string . If the -th character of is r
, the machine will play Rock in the -th round. Similarly, p
and s
stand for Paper and Scissors, respectively.
What is the maximum total score earned in the game by adequately choosing the hand to play in each round?
高桥(Takahashi)在一家游戏厅玩一款名为_RPS Battle_的游戏,游戏玩法如下:
- 玩家与机器玩 轮剪刀石头布。(有关 "剪刀石头布 "的说明,请参阅注释。平局也算一轮)。
- 每次玩家赢一轮,根据他/她使用的手,他/她会获得以下分数(平局或输了不计分):
- 用 "石头 "获胜得 分;
- 用剪刀获胜得 分;
- 用纸获胜得 分。
- 但是,在第 轮中,玩家不能使用在第 轮中使用过的手牌。(在前 轮中,玩家可以使用任何一手牌)。
游戏开始前,机器会决定每一轮的出牌方式。凭借超自然的力量,高桥成功地读取了所有这些手牌。
高桥获得的信息以 字符串的形式给出。如果 的第 个字符 是 的话 是
r
,那么机器就会在第 轮中出 Rock。同样,p
和s
分别代表 Paper(纸)和 Scissors(剪刀)。如果在每一轮中都充分选择出牌,那么在游戏中获得的最高总分是多少?
输入格式
输入内容按以下格式标准输入:
输出格式
打印游戏中获得的最高总分。
样例 #1
样例输入 #1
5 2
8 7 6
rsrpr
样例输出 #1
27
样例 #2
样例输入 #2
7 1
100 10 1
ssssppr
样例输出 #2
211
样例 #3
样例输入 #3
30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr
样例输出 #3
4996
说明
在这个问题中,"石头剪子布 "可以看作是一个双人游戏,每个玩家同时用一只手组成 "石头"、"剪子 "或 "布"。
- 如果一方选择 "石头",另一方选择 "剪刀",则选择 "石头 "的一方获胜;
- 如果一方选择 "剪刀",另一方选择 "纸",则选择 "剪刀 "的一方获胜;
- 如果一方选择纸,另一方选择石头,则选择纸的一方获胜;
- 如果双方都玩相同的牌,则平局。
数据规模与约定
- 和 都是整数。
- 由
r
,p
和s
组成。
样例 解释
机器将播放 {Rock, Scissors, Rock, Paper, Rock}.
例如,我们可以和它玩{纸、石头、石头、剪刀、布},从而获得 分。我们无法获得更多的分数,因此答案为 。