QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#9598. 派对动物

统计

小马 Macaronlin 是一位喜欢为朋友举办派对的派对动物。有一天,他邀请了 $n$ 位朋友参加他的家庭派对。作为一名派对专家,他为朋友们准备了许多游戏,其中包括“多人石头剪刀布”。

石头剪刀布是世界上广为人知的游戏,每位玩家同时做出三种手势之一:石头(rock)、布(paper)和剪刀(scissors)。石头胜剪刀,剪刀胜布,布胜石头。如果两位玩家选择相同的手势,则为平局。

“多人石头剪刀布”是该游戏的多人版本。在这个游戏中,$n$ 位玩家从左到右排成一排,编号为 $1$ 到 $n$。主持人 Macaronlin 会为每一轮选择一个区间 $[l, r]$,该区间内的玩家将按顺序进行游戏。具体来说,玩家 $l$ 和 $l+1$ 先进行游戏,然后是 $l+1$ 和 $l+2$,以此类推,最后是 $r-1$ 和 $r$。

Macaronlin 发现他的朋友们玩游戏的策略非常简单。最初,每位玩家都有一个偏好的手势,即石头、布或剪刀中的一种。当两名玩家进行游戏时,他们都会使用自己当前偏好的手势。一旦某位玩家输掉了比赛,他的偏好手势会立即变为击败他的那个手势。否则,他的偏好手势将保持不变,包括两人选择相同手势导致平局的情况。

Macaronlin 打算进行多轮游戏。他想知道在经过若干轮游戏后,某位玩家当前偏好的手势是什么。形式上,有两种类型的操作:

  • $1 \ l \ r$:Macaronlin 选择一个区间 $[l, r]$,该区间内的玩家按顺序进行游戏。具体来说,玩家 $l$ 和 $l+1$ 先进行游戏,然后是 $l+1$ 和 $l+2$,以此类推,最后是 $r-1$ 和 $r$。
  • $2 \ x$:Macaronlin 想知道编号为 $x$ 的玩家当前偏好的手势。

请回答 Macaronlin 关于第二类操作的询问。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 2 \times 10^5$),分别表示玩家数量和操作次数。

第二行包含一个长度为 $n$ 的字符串,由 R、P 和 S 组成,分别代表石头、布和剪刀。第 $i$ 个字符表示编号为 $i$ 的玩家最初偏好的手势。

接下来的 $m$ 行,每行表示一个操作,格式为 $1 \ l \ r$ ($1 \le l < r \le n$) 或 $2 \ x$ ($1 \le x \le n$)。

输出格式

对于每个第二类操作,输出一个字符,表示该玩家当前偏好的手势(R、P 或 S)。

样例

样例输入 1

10 10
RPSPSSRRPS
1 1 5
1 2 6
1 3 7
1 4 8
1 2 9
2 9
2 5
1 3 6
2 8
2 3

样例输出 1

P
R
P
R

样例输入 2

10 10
SRPSPRPRPR
2 10
1 2 9
2 1
2 6
2 3
1 1 7
2 2
1 4 9
1 2 8
2 7

样例输出 2

R
S
P
S
S

说明

对于第一个样例,每次操作的变化如下:

  1. RPSPSSRRPS → PSSSSSRRPS
  2. PSSSSSRRPS → PSSSSSRRPS
  3. PSSSSSRRPS → PSSSSRRRPS
  4. PSSSSRRRPS → PSSSRRRRPS
  5. PSSSRRRRPS → PSSRRRRPPS
  6. PSSRRRRP[P]S
  7. PSSR[R]RRPPS
  8. PSSRRRRPPS → PSRRRRRPPS
  9. PSRRRRR[P]PS
  10. PS[R]RRRRPPS

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.