AtCoder Regular Contest 109
C
Large RPS Tournament
AtCoder
⌀ 1157
原题
← BD →
翻译中…

Problem Statement

翻译中…

To decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament. There are $2^k$ players in this tournament, numbered $0$ through $2^k-1$. Each player has his/her favorite hand, which he/she will use in every match.

翻译中…

A string $s$ of length $n$ consisting of R, P, and S represents the players' favorite hands. Specifically, the favorite hand of Player $i$ is represented by the $((i\text{ mod } n) + 1)$-th character of $s$; R, P, and S stand for Rock, Paper, and Scissors, respectively.

翻译中…

For $l$ and $r$ such that $r-l$ is a power of $2$, the winner of the tournament held among Players $l$ through $r-1$ will be determined as follows:

翻译中…
  • If $r-l=1$ (that is, there is just one player), the winner is Player $l$.
  • If $r-l\geq 2$, let $m=(l+r)/2$, and we hold two tournaments, one among Players $l$ through $m-1$ and the other among Players $m$ through $r-1$. Let $a$ and $b$ be the respective winners of these tournaments. $a$ and $b$ then play a match of rock paper scissors, and the winner of this match - or $a$ if the match is drawn - is the winner of the tournament held among Players $l$ through $r-1$.
翻译中…

Find the favorite hand of the winner of the tournament held among Players $0$ through $2^k-1$.

翻译中…

Note

翻译中…
  • $a\text{ mod } b$ denotes the remainder when $a$ is divided by $b$.
  • The outcome of a match of rock paper scissors is determined as follows:
  • If both players choose the same hand, the match is drawn;
    • R beats S;
    • P beats R;
    • S beats P.
翻译中…

Constraints

翻译中…
  • $1 \leq n,k \leq 100$
  • $s$ is a string of length $n$ consisting of R, P, and S.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

n k
s

翻译中…

Output

翻译中…

Print the favorite hand of the winner of the tournament held among Players $0$ through $2^k-1$, as R, P, or S.

翻译中…

样例

Input #1
3 2
RPS
Output #1
P
- The favorite hand of the winner of the tournament held among Players $0$ through $1$ is `P`. - The favorite hand of the winner of the tournament held among Players $2$ through $3$ is `R`. - The favorite hand of the winner of the tournament held among Players $0$ through $3$ is `P`. Thus, the answer is `P`.
Input #2
11 1
RPSSPRSPPRS
Output #2
P
Input #3
1 100
S
Output #3
S
题目信息
题号
arc109_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。