CF1085F.Rock-Paper-Scissors Champion
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
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?
n 名玩家将参加一场“石头剪刀布”锦标赛。众所周知,在一场一对一的石头剪刀布比赛中,两名玩家各自独立地选择自己的手势。比赛结果由双方所选手势决定:“布”胜“石头”,“石头”胜“剪刀”,“剪刀”胜“布”;若双方选择相同的手势,则为平局。
锦标赛开始时,所有玩家排成一列,从左至右依次编号为 1 至 n。每名玩家在整场锦标赛中均固定使用其预先选定的手势。锦标赛按如下规则进行:
- 若场上仅剩一名玩家,则该玩家被宣布为冠军;
- 否则,任意选择当前队列中两名相邻的玩家进行下一场比赛。负者被淘汰出锦标赛,并从队列中离开(其原先的左右邻位玩家因此变为相邻)。若比赛结果为平局,则通过抛硬币随机决定负者。
主办方已获知所有玩家的首选手势。他们希望计算出可能成为锦标赛冠军的玩家总数(即:存在某种合适的比赛顺序以及对抛硬币结果的恰当操控,使得该玩家最终夺冠)。然而,部分玩家仍在优化策略,可能随时向主办方告知其更改后的新手势。请在每次此类更新请求之后,输出当前可能成为冠军的玩家人数。
输入格式
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).
第一行包含两个整数 n 和 q —— 分别表示玩家数量和请求次数(1≤n≤2⋅105,0≤q≤2⋅105)。
第二行包含一个长度为 n 的字符串。该字符串中第 i 个字符为 "R"、"P" 或 "S",分别表示玩家 i 在所有请求生效前原本打算出“石头”、“布”或“剪刀”。
接下来的 q 行描述了这些请求。其中第 j 行包含一个整数 pj 和一个字符 cj,表示从此时起玩家 pj 将改用由字符 cj 所代表的手势(1≤pj≤n)。
输出格式
Print q+1 integers r0,…,rq, where rk is the number of possible champions after processing k requests.
输出 q+1 个整数 r0,…,rq,其中 rk 表示处理完前 k 个请求后可能的冠军数量。
输入输出样例
输入#1
3 5 RPS 1 S 2 R 3 P 1 P 2 P
输出#1
2 2 1 2 2 3
输入解题思路,AI测评打分。不知道怎么写?