CF1085F.Rock-Paper-Scissors Champion
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
n players are going to play a rock-paper-scissors tournament. As you probably know, in a one-on-one match of rock-paper-scissors, two players choose their shapes independently. The outcome is then determined depending on the chosen shapes: "paper" beats "rock", "rock" beats "scissors", "scissors" beat "paper", and two equal shapes result in a draw.
At the start of the tournament all players will stand in a row, with their numbers increasing from 1 for the leftmost player, to n for the rightmost player. Each player has a pre-chosen shape that they will use in every game throughout the tournament. Here's how the tournament is conducted:
- If there is only one player left, he is declared the champion.
- Otherwise, two adjacent players in the row are chosen arbitrarily, and they play the next match. The losing player is eliminated from the tournament and leaves his place in the row (with his former neighbours becoming adjacent). If the game is a draw, the losing player is determined by a coin toss.
The organizers are informed about all players' favoured shapes. They wish to find out the total number of players who have a chance of becoming the tournament champion (that is, there is a suitable way to choose the order of the games and manipulate the coin tosses). However, some players are still optimizing their strategy, and can inform the organizers about their new shapes. Can you find the number of possible champions after each such request?
输入格式
The first line contains two integers n and q — the number of players and requests respectively ( 1≤n≤2⋅105 , 0≤q≤2⋅105 ).
The second line contains a string of n characters. The i -th of these characters is "R", "P", or "S" if the player i was going to play "rock", "paper", or "scissors" before all requests respectively.
The following q lines describe the requests. The j -th of these lines contain an integer pj and a character cj meaning that the player pj is going to use the shape described by the character cj from this moment ( 1≤pj≤n ).
输出格式
Print q+1 integers r0,…,rq , where rk is the number of possible champions after processing k requests.
输入输出样例
输入#1
3 5 RPS 1 S 2 R 3 P 1 P 2 P
输出#1
2 2 1 2 2 3