description
stringlengths 171
4k
| code
stringlengths 94
3.98k
| normalized_code
stringlengths 57
4.99k
|
|---|---|---|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
while t:
t -= 1
a = list(input())
prs = [0, 0, 0]
for i in a:
if i == "P":
prs[0] += 1
elif i == "R":
prs[1] += 1
elif i == "S":
prs[2] += 1
if prs[0] >= prs[1] and prs[0] >= prs[2]:
ans = "S"
elif prs[1] >= prs[0] and prs[1] >= prs[2]:
ans = "P"
else:
ans = "R"
for i in range(len(a)):
print(ans, end="")
print()
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
l = input()
d = {"R": "P", "P": "S", "S": "R"}
figures = ["R", "P", "S"]
counts = [l.count("R"), l.count("P"), l.count("S")]
print(d[figures[counts.index(max(counts))]] * len(l))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = list(input())
R = s.count("R")
S = s.count("S")
P = s.count("P")
m = max(R, max(S, P))
R -= m
S -= m
P -= m
if R == 0:
print("P" * len(s))
elif S == 0:
print("R" * len(s))
elif P == 0:
print("S" * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
n = int(input())
for _ in range(0, n):
a = input()
x = len(a)
p = 0
r = 0
s = 0
for i in range(0, len(a)):
if a[i] == "R":
r += 1
if a[i] == "P":
p += 1
if a[i] == "S":
s += 1
if p >= s and p >= r:
while x:
print("S", end="")
x -= 1
elif s >= p and s >= r:
while x:
print("R", end="")
x -= 1
elif r >= p and r >= s:
while x:
print("P", end="")
x -= 1
print()
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR WHILE VAR EXPR FUNC_CALL VAR STRING STRING VAR NUMBER IF VAR VAR VAR VAR WHILE VAR EXPR FUNC_CALL VAR STRING STRING VAR NUMBER IF VAR VAR VAR VAR WHILE VAR EXPR FUNC_CALL VAR STRING STRING VAR NUMBER EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
cases = int(input())
for i in range(cases):
s = input()
rock = "R"
scis = "S"
pape = "P"
ans = ""
r1 = s.count(rock)
s1 = s.count(scis)
p1 = s.count(pape)
ma = max(r1, s1, p1)
if ma == r1:
ans += len(s) * "P"
elif ma == s1:
ans += len(s) * "R"
elif ma == p1:
ans += len(s) * "S"
print(ans)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
a = {"R": 0, "S": 0, "P": 0}
b = {"R": "P", "S": "R", "P": "S"}
for i in s:
a[i] += 1
val = max(a, key=a.get)
print(b[val] * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
while t:
t -= 1
s = input()
n = len(s)
d = {"R": 0, "P": 0, "S": 0}
for i in range(n):
d[s[i]] += 1
if d["R"] == max(d.values()):
print("P" * n)
elif d["P"] == max(d.values()):
print("S" * n)
elif d["S"] == max(d.values()):
print("R" * n)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR STRING FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR STRING FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR STRING FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for testcase in range(int(input())):
s = input().strip()
cnt = {"R": 0, "S": 0, "P": 0}
for i in s:
cnt[i] += 1
_, w = max(zip(cnt.values(), cnt.keys()))
ans = {"R": "P", "P": "S", "S": "R"}[w] * len(s)
print(ans)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP DICT STRING STRING STRING STRING STRING STRING VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for i in range(t):
ch = input()
n = len(ch)
nbR = ch.count("R")
nbS = ch.count("S")
nbP = ch.count("P")
L = [nbR, nbS, nbP]
if nbR == max(L):
print("P" * n)
elif nbS == max(L):
print("R" * n)
else:
print("S" * n)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
while t > 0:
s = str(input())
R = s.count("R")
P = s.count("P")
S = s.count("S")
A = max(R, P, S)
n = len(s)
if A == R:
for i in range(n):
print("P", end="")
elif A == P:
for j in range(n):
print("S", end="")
elif A == S:
for k in range(n):
print("R", end="")
print("\t")
t = t - 1
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
s = int(input())
for tc in range(s):
d = {}
string = input()
for i in string:
if i in d:
d[i] += 1
else:
d[i] = 1
sorted_d = sorted(d.items(), key=lambda x: x[1])
letter = sorted_d[-1][0]
if letter == "R":
ans = "P"
elif letter == "P":
ans = "S"
if letter == "S":
ans = "R"
for i in range(len(string)):
print(ans, end="")
print("")
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for t in range(int(input())):
s = input()
l = [0] * 3
n = len(s)
for z in range(n):
if s[z] == "R":
l[0] += 1
elif s[z] == "P":
l[1] += 1
else:
l[-1] += 1
idx = l.index(max(l))
if idx == 0:
ans = ["P"] * n
elif idx == 1:
ans = ["S"] * n
else:
ans = ["R"] * n
print("".join(ans))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for i in range(t):
s = str(input())
n = len(s)
a = ""
s1 = 0
s2 = 0
s3 = 0
for j in range(n):
if s[j] == "R":
s1 += 1
elif s[j] == "P":
s2 += 1
else:
s3 += 1
lis = [s1, s2, s3]
lis.sort()
if lis[-1] != lis[-2]:
if s1 == lis[-1]:
for j in range(n):
a += "P"
print(a)
elif s2 == lis[-1]:
for j in range(n):
a += "S"
print(a)
else:
for j in range(n):
a += "R"
print(a)
elif lis[-1] == lis[-2] and lis[-2] != lis[-3]:
if s1 == lis[0]:
for j in range(n):
a += "R"
print(a)
elif s2 == lis[0]:
for j in range(n):
a += "P"
print(a)
else:
for j in range(n):
a += "S"
print(a)
else:
for j in range(n):
a += "P"
print(a)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def solve():
s = input()
d = {"R": 0, "S": 0, "P": 0}
for c in s:
d[c] += 1
m = max(d.values())
print(len(s) * "PRS"[[*d.values()].index(m)])
def main():
for _ in range(int(input())):
solve()
main()
|
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL LIST FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
n = len(s)
d = {"R": "P", "P": "S", "S": "R"}
freq = {}
for i in s:
freq[i] = freq.get(i, 0) + 1
maxx = max(freq, key=freq.get)
ans = d[maxx] * n
print(ans)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
from sys import *
t = int(stdin.readline())
while t > 0:
s = stdin.readline()
d = dict()
for i in range(len(s)):
if s[i] not in d:
d[s[i]] = 1
else:
d[s[i]] += 1
dk = max(d, key=d.get)
if dk == "R":
ans = "P"
if dk == "P":
ans = "S"
if dk == "S":
ans = "R"
l = [ans for i in range(len(s) - 1)]
print("".join(l))
t -= 1
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR NUMBER
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
n = int(input())
for i in range(n):
string = str(input())
flag = 0
r = 0
s = 0
p = 0
for j in range(0, len(string)):
if string[j] == "R":
r = r + 1
elif string[j] == "S":
s = s + 1
elif string[j] == "P":
p = p + 1
m = 0
if r >= s:
if r >= p:
for j in range(len(string)):
print("P", end="")
print()
elif p >= s:
for j in range(len(string)):
print("S", end="")
print()
elif s >= p:
for j in range(len(string)):
print("R", end="")
print()
elif len(string) == 2:
if s == 0:
print("SS")
elif r == 0:
print("RR")
elif p == 0:
print("PP")
else:
print(string)
elif s >= p:
for j in range(len(string)):
print("R", end="")
print()
elif p >= s:
for j in range(len(string)):
print("S", end="")
print()
elif len(string) == 2:
if s == 0:
print("SS")
elif r == 0:
print("RR")
elif p == 0:
print("PP")
else:
print(string)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for u in range(int(input())):
s = input()
n = len(s)
h = dict()
l = ["R", "S", "P"]
r = ["P", "R", "S"]
for i in l:
h[s.count(i)] = i
t = max(h)
out = [r[l.index(h[t])]] * n
print("".join(out))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
tmp = {s.count("S"): "S", s.count("P"): "P", s.count("R"): "R"}
tmp = tmp[max(tmp)]
ans = {"R": "P", "S": "R", "P": "S"}
print(ans[tmp] * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING STRING STRING ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for z in range(int(input())):
s = input()
d = {"R": 0, "P": 0, "S": 0}
for c in s:
d[c] += 1
mc = max(d, key=d.get)
print({"R": "P", "P": "S", "S": "R"}[mc] * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP DICT STRING STRING STRING STRING STRING STRING VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def in1():
return int(input())
for _ in range(in1()):
s = list(input())
d = [0, 0, 0]
for i in range(len(s) - 1, -1, -1):
if s[i] == "R":
d[0] += 1
elif s[i] == "S":
d[1] += 1
else:
d[2] += 1
s1 = ""
t1 = max(d)
t2 = d.index(t1)
if t2 == 0:
s1 = "P" * len(s)
elif t2 == 1:
s1 = "R" * len(s)
else:
s1 = "S" * len(s)
print(s1)
|
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def solve():
lst = list(input())
n = len(lst)
r = 0
s = 0
p = 0
for i in lst:
if i == "R":
p += 1
if i == "S":
r += 1
if i == "P":
s += 1
q = max([r, s, p])
if r == q:
print("R" * n)
elif s == q:
print("S" * n)
else:
print("P" * n)
for i in range(int(input())):
solve()
|
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
arr = list(input())
a = arr.count("R")
b = arr.count("P")
c = arr.count("S")
if a == b == c:
print("".join(arr))
elif a is max(a, b, c):
arr2 = ["P"] * len(arr)
print("".join(arr2))
elif b is max(a, b, c):
arr2 = ["S"] * len(arr)
print("".join(arr2))
else:
arr2 = ["R"] * len(arr)
print("".join(arr2))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for i in range(t):
s = input()
l = len(s)
m = 0
for each in set(s):
if s.count(each) > m:
m = s.count(each)
x = each
if x == "R":
print("P" * l)
elif x == "S":
print("R" * l)
elif x == "P":
print("S" * l)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
d = dict()
d["R"] = 0
d["S"] = 0
d["P"] = 0
d1 = dict()
d1["R"] = "P"
d1["S"] = "R"
d1["P"] = "S"
for i in s:
d[i] += 1
ans = ""
c = ""
mx = -1
for i in list(d.items()):
if mx < i[1]:
c = d1[i[0]]
mx = i[1]
print(c * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING STRING ASSIGN VAR STRING STRING ASSIGN VAR STRING STRING FOR VAR VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
import sys
input = sys.stdin.readline
inp, ip = lambda: int(input()), lambda: [int(w) for w in input().split()]
for _ in range(inp()):
s = input().strip()
n = len(s)
dt = {}
for i in s:
dt[i] = dt.get(i, 0) + 1
mx = -1
for i in dt:
if dt[i] == max(dt.values()):
mx = i
game = ["P", "S", "R"]
print(game[(game.index(mx) + 1) % 3] * n)
|
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def maximum(a, b, c):
list = [a, b, c]
return max(list)
n = int(input())
for i in range(0, n):
s = str(input())
a = list(s)
countp = 0
counts = 0
countr = 0
b = len(s)
for j in range(b):
if a[j] == "R":
countr += 1
elif a[j] == "P":
countp += 1
elif a[j] == "S":
counts += 1
x = maximum(counts, countp, countr)
if countp == x:
for j in range(b):
a[j] = "S"
if counts == x:
for j in range(b):
a[j] = "R"
if countr == x:
for j in range(b):
a[j] = "P"
z = "".join(a)
print(z)
|
FUNC_DEF ASSIGN VAR LIST VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
a = input().strip()
n = len(a)
r, p, s = a.count("R"), a.count("P"), a.count("S")
if r == 0 and p == 0:
print("R" * n)
elif p == 0 and s == 0:
print("P" * n)
elif s == 0 and r == 0:
print("S" * n)
elif r == p and p == s and s == r:
print("R" * n)
elif r >= p and r >= s:
print("P" * n)
elif p >= r and p >= s:
print("S" * n)
elif s >= r and s >= p:
print("R" * n)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
d = {"R": "P", "S": "R", "P": "S"}
print(d[max("RSP", key=lambda x: s.count(x))] * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def mi():
return map(int, input().split())
def ii():
return int(input())
def li():
return list(map(int, input().split()))
def si():
return input().split()
t = ii()
ans = [
"PPP",
"PPR",
"PPS",
"PRP",
"PRR",
"PRS",
"PSP",
"PSR",
"PSS",
"RPP",
"RPR",
"RPS",
"RRP",
"RRR",
"RRS",
"RSP",
"RSR",
"RSS",
"SPP",
"SPR",
"SPS",
"SRP",
"SRR",
"SRS",
"SSP",
"SSR",
"SSS",
]
for _ in range(t):
s = input()
r, p, c = 0, 0, 0
for i in s:
if i == "S":
c += 1
if i == "P":
p += 1
if i == "R":
r += 1
ma = max(r, c, p)
if ma == r and ma == c and ma == p:
print("PRS" * ma)
elif r == ma:
print("P" * len(s))
elif c == ma:
print("R" * len(s))
else:
print("S" * len(s))
|
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
s = str(input())
n = len(s)
d = {}
for x in s:
if x in d:
d[x] += 1
else:
d[x] = 1
mn = -1
fx = None
for x in d:
if mn < d[x]:
mn = d[x]
fx = x
if fx == "R":
c = "P" * n
elif fx == "P":
c = "S" * n
else:
c = "R" * n
print(c)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR STRING ASSIGN VAR BIN_OP STRING VAR IF VAR STRING ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
r = {"S": "R", "P": "S", "R": "P"}
for _ in range(int(input())):
s = input()
sc, pc, rc = s.count("S"), s.count("P"), s.count("R")
if max(sc, pc, rc) == sc:
print(r["S"] * len(s))
elif max(sc, pc, rc) == pc:
print(r["P"] * len(s))
elif max(sc, pc, rc) == rc:
print(r["R"] * len(s))
|
ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
n = input()
r, p, s = 0, 0, 0
for i in n:
if i == "R":
r += 1
elif i == "P":
p += 1
else:
s += 1
if r >= p and r >= s:
print("P" * len(n))
elif p >= r and p >= s:
print("S" * len(n))
else:
print("R" * len(n))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
tests = int(input())
for test in range(tests):
s = input()
cnt = {"P": 0, "R": 0, "S": 0}
for ch in s:
cnt[ch] += 1
best = "P"
for k, v in cnt.items():
if cnt[best] < v:
best = k
winner = {"P": "S", "R": "P", "S": "R"}
print(winner[best] * len(s))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
s = str(input())
n = len(s)
a = {"R", "P", "S"}
r = s.count("R")
p = s.count("P")
s = s.count("S")
if r == max(r, p, s):
ans = n * "P"
elif p == max(r, p, s):
ans = n * "S"
else:
ans = n * "R"
print(ans)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING STRING STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR STRING IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
def majorityCnt(classList):
count_dict = {}
for label in classList:
if label not in count_dict.keys():
count_dict[label] = 0
count_dict[label] += 1
return max(zip(count_dict.values(), count_dict.keys()))[1]
for _ in range(t):
s = list(input())
res_dict = {"S": "R", "R": "P", "P": "S"}
print(res_dict[majorityCnt(s)] * len(s))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
tests = int(input())
for t in range(tests):
string = input()
roks = 0
paper = 0
scissor = 0
for n in range(len(string)):
if string[n] == "R":
roks += 1
elif string[n] == "P":
paper += 1
else:
scissor += 1
print_str = (
"P" * (roks >= max(scissor, paper))
+ "S" * (paper > max(roks, scissor))
+ "R" * (scissor > max(roks, paper))
)
if len(print_str) == 0:
print_str = (
"P" * (roks == paper > scissor)
+ "R" * (roks == scissor > paper)
+ "S" * (scissor == paper > roks)
)
print(print_str * len(string))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR FUNC_CALL VAR VAR VAR BIN_OP STRING VAR FUNC_CALL VAR VAR VAR BIN_OP STRING VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR VAR VAR BIN_OP STRING VAR VAR VAR BIN_OP STRING VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = str(input())
l = list(s)
x = l.count("R")
y = l.count("S")
z = l.count("P")
if x >= y and x >= z:
for i in range(len(s)):
print("P", end="")
elif y >= x and y >= z:
for i in range(len(s)):
print("R", end="")
elif z >= x and z >= y:
for i in range(len(s)):
print("S", end="")
print()
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
a = input()
n = len(a)
x = a.count("R")
y = a.count("S")
z = a.count("P")
if x == y == z:
print("".join(a), end="")
elif max(x, y, z) == x:
for i in range(n):
print("P", end="")
elif max(x, y, z) == y:
for i in range(n):
print("R", end="")
elif max(x, y, z) == z:
for i in range(n):
print("S", end="")
print()
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
n = str(input())
r = 0
p = 0
s = 0
for i in n:
if i == "R":
r += 1
if i == "P":
p += 1
if i == "S":
s += 1
if r == p == s:
print(n)
elif max(r, p, s) == r:
print("P" * len(n))
elif max(r, p, s) == p:
print("S" * len(n))
elif max(r, p, s) == s:
print("R" * len(n))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for i in range(int(input())):
s = input()
a = {"P": 0, "R": 0, "S": 0}
for i in range(len(s)):
a[s[i]] += 1
ma = max(a["P"], a["R"], a["S"])
if a["R"] == ma:
ans = "P" * len(s)
elif a["P"] == ma:
ans = "S" * len(s)
elif a["S"] == ma:
ans = "R" * len(s)
print(ans)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING VAR STRING VAR STRING IF VAR STRING VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR STRING VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR STRING VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for ty in range(int(input())):
s = list(input())
p = 0
r = 0
o = 0
for i in range(len(s)):
if s[i] == "R":
s[i] = "P"
p += 1
elif s[i] == "S":
s[i] = "R"
r += 1
else:
s[i] = "S"
o += 1
if max(p, o, r) == p:
print("P" * len(s))
elif max(p, o, r) == o:
print("S" * len(s))
else:
print("R" * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
o = max("RSP", key=lambda x: s.count(x))
if o == "R":
o = "P"
elif o == "S":
o = "R"
else:
o = "S"
print(o * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
ip = input()
n = len(ip)
l = [0, 0, 0]
d = {"r": 0, "p": 0, "s": 0}
for i in ip:
if i == "R":
d["r"] += 1
elif i == "P":
d["p"] += 1
else:
d["s"] += 1
d1 = sorted(d.items(), key=lambda x: x[1], reverse=True)
temp = d1[0][0]
if temp == "r":
print("P" * n)
elif temp == "p":
print("S" * n)
else:
print("R" * n)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR STRING NUMBER IF VAR STRING VAR STRING NUMBER VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = list(input())
s1 = set(s)
if len(s1) == 1:
if s[0] == "R":
print("P" * len(s))
elif s[0] == "P":
print("S" * len(s))
else:
print("R" * len(s))
else:
p = s.count("P")
r = s.count("R")
ss = s.count("S")
m = max(p, r, ss)
if m == p:
print("S" * len(s))
elif m == r:
print("P" * len(s))
else:
print("R" * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
n = int(input())
d = {"R": "P", "P": "S", "S": "R"}
for _ in range(n):
cnt = {"R": 0, "P": 0, "S": 0}
s = input()
for x in s:
cnt[x] += 1
for x in cnt.keys():
if cnt[x] == max(cnt.values()):
ans = x
print(d[ans] * len(s))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def most_frequent(lineup):
ans = {}
for i in lineup:
if i in ans:
ans[i] += 1
else:
ans[i] = 1
max_value = -1
for j in ans:
max_value = max(max_value, ans[j])
if max_value == ans[j]:
printed = j
if printed == "R":
return "P"
elif printed == "P":
return "S"
else:
return "R"
for i in range(int(input())):
lineup = list(input())
tobeprint = []
print(*([most_frequent(lineup)] * len(lineup)), sep="")
|
FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR STRING RETURN STRING IF VAR STRING RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
r = "R"
p = "P"
s = "S"
c = [r, p, s]
for _ in range(int(input())):
n = input()
a = {r: 0, p: 0, s: 0}
for v in n:
a[v] += 1
best = 0
bc = r
for k, v in a.items():
if v > best:
best = v
bc = k
print(c[(c.index(bc) + 1) % 3] * len(n))
|
ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
s = input()
rcount = 0
pcount = 0
scount = 0
for i in range(len(s)):
if s[i] == "R":
rcount += 1
if s[i] == "S":
scount += 1
if s[i] == "P":
pcount += 1
ans = []
if rcount >= pcount and rcount >= scount:
for i in range(len(s)):
ans.append("P")
elif scount >= pcount and scount >= rcount:
for i in range(len(s)):
ans.append("R")
else:
for i in range(len(s)):
ans.append("S")
print("".join(ans))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR LIST IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
from sys import stdin
input = lambda: stdin.readline().rstrip()
for _ in range(int(input())):
s = input()
n = len(s)
S = R = P = 0
for i in s:
if i == "S":
S += 1
elif i == "R":
R += 1
else:
P += 1
k = max(S, R, P)
if k == S:
ans = "R"
elif k == R:
ans = "P"
else:
ans = "S"
print(ans * n)
|
ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR STRING IF VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
opp = {"R": "P", "S": "R", "P": "S"}
counts = {"R": 0, "S": 0, "P": 0}
hi, bestC = 0, "R"
for c in s:
counts[c] += 1
if counts[c] > hi:
hi = counts[c]
bestC = c
print(opp[bestC] * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER STRING FOR VAR VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for x in range(t):
s = list(input())
rocks = s.count("R")
scissors = s.count("S")
paper = s.count("P")
if rocks == scissors and paper == scissors:
print("".join(s))
elif rocks == max(scissors, paper, rocks):
print("P" * len(s))
elif paper == max(scissors, paper, rocks):
print("S" * len(s))
else:
print("R" * len(s))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
T = int(input())
for _ in range(T):
arr = input().strip()
n = len(arr)
R, P, S = 0, 0, 0
for ch in arr:
if ch == "R":
R += 1
elif ch == "P":
P += 1
else:
S += 1
maxc = max(max(R, P), S)
ans = ""
if R == maxc:
for i in range(n):
ans += "P"
elif P == maxc:
for i in range(n):
ans += "S"
else:
for i in range(n):
ans += "R"
print(ans)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
x = ["R", "S", "P"]
for _ in range(t):
s = list(input())
n = len(s)
cnt = [s.count(x[i]) for i in range(3)]
c = x[(cnt.index(max(cnt)) - 1) % 3]
print(c * n)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
a = input()
r = a.count("R")
p = a.count("P")
s = a.count("S")
if r >= p and r >= s:
print("P" * len(a))
elif p >= r and p >= s:
print("S" * len(a))
elif s >= p and s >= r:
print("R" * len(a))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for q in range(t):
s = input()
n = len(s)
hs = [0, 0, 0]
for i in range(n):
if s[i] == "R":
hs[0] += 1
elif s[i] == "P":
hs[1] += 1
else:
hs[2] += 1
c = "P"
if hs[0] == max(hs):
c = "P"
elif hs[1] == max(hs):
c = "S"
else:
c = "R"
for i in range(n):
print(c, end="")
print()
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR STRING IF VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for t in range(int(input())):
s = input()
d = {}
for i in s:
if i in d:
d[i] += 1
else:
d[i] = 1
keylist = list(d.keys())
vallist = list(d.values())
m = 0
for i in d:
if m < d[i]:
m = d[i]
res = keylist[vallist.index(m)]
if res == "R":
print("P" * len(s))
elif res == "S":
print("R" * len(s))
else:
print("S" * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
dem1 = 0
dem2 = 0
dem3 = 0
result = ""
dem1 = s.count("R")
dem2 = s.count("S")
dem3 = s.count("P")
m = max(dem1, dem2, dem3)
if dem1 == m:
ans = "P"
elif dem2 >= dem3 and dem2 >= dem1:
ans = "R"
else:
ans = "S"
print(ans * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR STRING IF VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for nt in range(int(input())):
string = input()
n = len(string)
r, s, p = 0, 0, 0
for i in string:
if i == "R":
r += 1
elif i == "S":
s += 1
else:
p += 1
new = [[r, "R"], [s, "S"], [p, "P"]]
new.sort()
win = new[-1][1]
if win == "R":
ans = "P" * n
elif win == "P":
ans = "S" * n
else:
ans = "R" * n
print(ans)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR LIST LIST VAR STRING LIST VAR STRING LIST VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR STRING ASSIGN VAR BIN_OP STRING VAR IF VAR STRING ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
dic = {"S": "R", "R": "P", "P": "S"}
d = {"S": 0, "R": 0, "P": 0}
for i in s:
d[i] += 1
if d["S"] == max(d.values()):
print("R" * len(s))
elif d["R"] == max(d.values()):
print("P" * len(s))
elif d["P"] == max(d.values()):
print("S" * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER IF VAR STRING FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR STRING FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR STRING FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for i in range(t):
rsp = list(input())
rpsstring = ""
rps = {"R": "P", "P": "S", "S": "R"}
rc = 0
pc = 0
sc = 0
for k in rsp:
if k == "R":
rc += 1
continue
elif k == "P":
pc += 1
continue
else:
sc += 1
if rc >= pc and rc >= sc:
print("P" * (rc + pc + sc))
elif pc > rc and pc >= sc:
print("S" * (rc + pc + sc))
elif sc > rc and sc > pc:
print("R" * (rc + pc + sc))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
import sys
def solve(a):
result = [" "] * len(a)
nr, np, ns = 0, 0, 0
for played in a:
if played == "R":
nr += 1
elif played == "P":
np += 1
elif played == "S":
ns += 1
MX = "R"
if max(nr, np, ns) == np:
MX = "S"
if max(nr, np, ns) == nr:
MX = "P"
for i in range(len(a)):
result[i] = MX
return "".join([str(x) for x in result])
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
cur = 1
for ti in range(T):
a = [x for x in IN[cur]]
result = solve(a)
print(result)
cur += 1
|
IMPORT FUNC_DEF ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def main(s):
hash = {}
flip = {"S": "R", "R": "P", "P": "S"}
for i in s:
if i not in hash:
hash[i] = 1
else:
hash[i] += 1
char = ""
c = 0
for i in hash:
if hash[i] > c:
c = hash[i]
char = i
print(flip[char] * len(s))
n = int(input())
for i in range(n):
s = input()
main(s)
|
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
ans = []
for i in range(t):
s = input()
c = dict()
k = 0
c["R"] = 0
c["P"] = 0
c["S"] = 0
for j in s:
c[j] += 1
for j in c:
k = max(k, c[j])
if c["R"] == k:
ans.append("P" * len(s))
elif c["P"] == k:
ans.append("S" * len(s))
else:
ans.append("R" * len(s))
for i in ans:
print(i)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def solve():
s = input()
ans = ""
op = {"R": "P", "S": "R", "P": "S"}
counter = {}
mx = s[0]
mxc = 1
for c in s:
counter.setdefault(c, 0)
counter[c] += 1
if counter[c] > mxc:
mxc = counter[c]
mx = c
ans = op[mx] * len(s)
print(ans)
t = int(input())
for _ in range(t):
solve()
|
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for test_i in range(int(input())):
s = input()
l = len(s)
n1, n2, n3 = s.count("R"), s.count("S"), s.count("P")
if n2 <= n1 >= n3:
print("P" * l)
elif n1 <= n2 >= n3:
print("R" * l)
else:
print("S" * l)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
x, y, z = 0, 0, 0
k = ""
for i in range(len(s)):
if s[i] == "R":
x += 1
elif s[i] == "S":
y += 1
else:
z += 1
if x >= y and x >= z:
k = k + "P" * len(s)
elif y >= x and y >= z:
k = k + "R" * len(s)
elif z >= x and z >= y:
k = k + "S" * len(s)
print(k)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def checker(orig, ans):
for i in range(len(orig)):
score = 0
cnt = 0
for j in range(i, i + len(orig)):
ind = j % len(orig)
if orig[ind] == "P" and ans[cnt] == "S":
score += 1
elif orig[ind] == "S" and ans[cnt] == "R":
score += 1
elif orig[ind] == "R" and ans[cnt] == "P":
score += 1
cnt += 1
print(i, score)
t = int(input())
for ii in range(t):
sp = input()
ans = []
r = 0
s = 0
p = 0
for i in sp:
if i == "R":
p += 1
elif i == "S":
r += 1
else:
s += 1
l = [(r, "R"), (s, "S"), (p, "P")]
l.sort()
ans = [l[-1][1]] * len(sp)
for i in ans:
print(i, end="")
print()
|
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER NUMBER FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
abc = int(input())
for x in range(abc):
s = input()
n = len(s)
n1 = s.count("R")
n2 = s.count("P")
n3 = n - n1 - n2
A = []
m = max(n1, n2, n3)
if m == n1:
A.append("P" * n)
elif m == n2:
A.append("S" * n)
else:
A.append("R" * n)
print("".join(A))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
ans = []
for _ in range(int(input())):
s = list(input())
n = len(s)
cnt = [0] * 3
for i in range(n):
if s[i] == "R":
cnt[0] += 1
elif s[i] == "P":
cnt[1] += 1
else:
cnt[2] += 1
if cnt[0] == max(cnt):
ansi = "P" * n
elif cnt[1] == max(cnt):
ansi = "S" * n
else:
ansi = "R" * n
ans.append(ansi)
print("\n".join(ans))
|
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER IF VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _t in range(t):
s = input()
h = ["R", "P", "S"]
h2 = ["R", "P", "S", "R"]
m = 0
sol = ""
for k in range(len(h)):
if s.count(h[k]) > m:
m = s.count(h[k])
sol = h2[k + 1]
for i in range(len(s)):
print(sol, end="")
print("")
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def sol(s: str) -> str:
R, S, P = s.count("R"), s.count("S"), s.count("P")
maxs = max(R, S, P)
if maxs == R:
return "P" * len(s)
elif maxs == S:
return "R" * len(s)
else:
return "S" * len(s)
tmp = []
p = print
def print(*args, **kwargs):
tmp.append((args, kwargs))
def flush():
for args, kwargs in tmp:
p(*args, **kwargs)
return
T = int(input())
for _ in range(T):
s = input()
out = sol(s)
print(out)
flush()
|
FUNC_DEF VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR RETURN BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR RETURN BIN_OP STRING FUNC_CALL VAR VAR RETURN BIN_OP STRING FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR FUNC_DEF FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
d = {"S": "R", "P": "S", "R": "P"}
for _ in range(int(input())):
s = input()
m = 0
c = ""
for i in d:
x = s.count(i)
if x >= m:
m = x
c = i
ans = d[c] * len(s)
print(ans)
|
ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
s = input()
n = len(s)
ans = ""
d = {}
for i in s:
if i not in d:
d[i] = 1
else:
d[i] += 1
a = list(d.keys())
move = a[0]
for i in d:
if d[i] > d[move]:
move = i
if move == "R":
move = "P"
elif move == "P":
move = "S"
else:
move = "R"
ans = n * move
print(ans)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR STRING ASSIGN VAR STRING IF VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
T = int(input())
while T > 0:
s = input()
dic = {"R": 0, "S": 1, "P": 2}
count = [0] * 3
for i in range(len(s)):
count[dic[s[i]]] += 1
x = 0
index = 0
for i in range(3):
if count[i] > x:
x = count[i]
index = i
if index == 0:
print("P" * len(s))
elif index == 1:
print("R" * len(s))
else:
print("S" * len(s))
T -= 1
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR VAR NUMBER
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
import sys
print = sys.stdout.write
dic = {"R": "P", "P": "S", "S": "R"}
for _ in range(int(input())):
s = input()
a = max(["R", "P", "S"], key=s.count)
print(dic[a] * len(s) + "\n")
|
IMPORT ASSIGN VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST STRING STRING STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR STRING
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
s = input()
L = len(s)
count = [0] * 3
for i in s:
if i == "R":
count[0] += 1
elif i == "P":
count[1] += 1
else:
count[2] += 1
if count[0] == max(count):
print("P" * L)
elif count[1] == max(count):
print("S" * L)
else:
print("R" * L)
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER IF VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for tc in range(int(input())):
A = input()
R = 0
S = 0
P = 0
for i in A:
exec(i + "+=1")
if R >= S and R >= P:
print("P" * len(A))
elif S >= R and S >= P:
print("R" * len(A))
else:
print("S" * len(A))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
__MULTITEST = True
def solve():
s = str(input())
play = {}
play["R"] = "P"
play["P"] = "S"
play["S"] = "R"
maxChar = "P"
for p in ["R", "S"]:
if s.count(p) > s.count(maxChar):
maxChar = p
tac = play[maxChar] * len(s)
print(tac)
t = int(input()) if __MULTITEST else 1
for tt in range(t):
solve()
|
ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING STRING ASSIGN VAR STRING STRING ASSIGN VAR STRING STRING ASSIGN VAR STRING FOR VAR LIST STRING STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for i in range(int(input())):
a = input()
if a.count("R") >= max(a.count("S"), a.count("P")):
print("P" * len(a))
elif a.count("S") >= max(a.count("R"), a.count("P")):
print("R" * len(a))
else:
print("S" * len(a))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
i = 0
while i < t:
s = input()
n = len(s)
countp = 0
countr = 0
counts = 0
for x in s:
if x == "P":
countp = countp + 1
if x == "R":
countr = countr + 1
if x == "S":
counts = counts + 1
res = [[countp, "P"], [countr, "R"], [counts, "S"]]
res = sorted(res, key=lambda x: x[0], reverse=True)
a = res[0][1]
if a == "P":
print("S" * n)
elif a == "R":
print("P" * n)
else:
print("R" * n)
i = i + 1
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST LIST VAR STRING LIST VAR STRING LIST VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for i in [*open(0)][1:]:
l = [i.count("S"), i.count("P"), i.count("R")]
print(["S", "P", "R"][l.index(max(l)) - 1] * (len(i) - 1))
|
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP LIST STRING STRING STRING BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def problemA():
n = int(input())
l = list(map(int, input().split()))
i = 0
while i < n - 1 and l[i] > l[i + 1]:
i += 1
if i == n - 1:
print("NO")
return
j = i + 1
while j < n - 1 and l[j] < l[j + 1]:
j += 1
if j == n - 1:
print("NO")
return
print("YES")
print(i + 1, j + 1, j + 2)
def problemB():
s = input().strip()
a = [0] * 3
for i in s:
if i == "R":
a[0] += 1
elif i == "S":
a[1] += 1
else:
a[2] += 1
m = max(a)
if a[0] == m:
print("P" * sum(a))
elif a[1] == m:
print("R" * sum(a))
else:
print("S" * sum(a))
cases = int(input())
for _ in range(cases):
problemB()
|
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
from sys import stdin, stdout
def main():
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
inp = stdin.readline().strip()
counter = {}
for i in inp:
if i not in counter:
counter[i] = 1
else:
counter[i] += 1
maxim = -1000000000.0
maxletter = None
for i in counter:
if counter[i] > maxim:
maxim = counter[i]
maxletter = i
ans = "R" if maxletter == "S" else "S" if maxletter == "P" else "P"
ans = ans * len(inp)
stdout.write(ans + "\n")
main()
|
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR STRING STRING VAR STRING STRING STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def solution():
for _ in range(int(input())):
s = input()
ans = ""
r = 0
p = 0
sc = 0
for i in s:
if i == "S":
sc += 1
elif i == "P":
p += 1
else:
r += 1
if max([r, sc, p]) == r:
ans = "P" * len(s)
elif max([r, sc, p]) == p:
ans = "S" * len(s)
else:
ans = "R" * len(s)
print(ans)
solution()
|
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF FUNC_CALL VAR LIST VAR VAR VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR LIST VAR VAR VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def multiple_input():
return map(int, input().split())
def list_input():
return list(map(int, input().split()))
for _ in range(int(input())):
x = input()
r, s, p = 0, 0, 0
for i in x:
if i == "R":
r += 1
elif i == "S":
s += 1
else:
p += 1
if r == s == p:
ans = x
elif r == s and r > p:
c = len(x) // 2
ans = c * "P" + c * "R"
if len(x) % 2 != 0:
ans += "R"
elif s == p and s > r:
c = len(x) // 2
ans = c * "R" + c * "S"
if len(x) % 2 != 0:
ans += "S"
elif r == p and r > s:
c = len(x) // 2
ans = c * "P" + c * "S"
if len(x) % 2 != 0:
ans += "S"
elif r > s and r > p:
ans = len(x) * "P"
elif s > r and s > p:
ans = len(x) * "R"
elif p > s and p > r:
ans = len(x) * "S"
print(ans)
|
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR STRING IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR STRING IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR STRING IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR STRING IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR STRING IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
def solve():
ss = input()
d = {}
d["R"] = 0
d["P"] = 0
d["S"] = 0
for i in ss:
d[i] += 1
r, p, s = d["R"], d["P"], d["S"]
e = max(r, max(p, s))
if e == r:
print("P" * len(ss))
elif e == p:
print("S" * len(ss))
else:
print("R" * len(ss))
for _ in range(int(input())):
solve()
|
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR STRING VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
sl = input()
r, s, p = 0, 0, 0
maxx = 0
c = "R"
for i in sl:
if i == "R":
r += 1
if r > maxx:
maxx = r
c = "P"
elif i == "S":
s += 1
if s > maxx:
maxx = s
c = "R"
else:
p += 1
if p > maxx:
maxx = p
c = "S"
print(c * len(sl))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING IF VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for T in range(int(input())):
s = input()
num = {"R": 0, "S": 0, "P": 0}
trans = {"R": "P", "S": "R", "P": "S"}
for i in s:
num[i] += 1
mx = max(num.values())
for i in num.keys():
if num[i] == mx:
for j in s:
print(trans[i], end="")
print()
break
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR IF VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
d = {}
d["R"] = "P"
d["P"] = "S"
d["S"] = "R"
for n in range(int(input())):
s = list(input())
v = {}
v["R"] = s.count("R")
v["P"] = s.count("P")
v["S"] = s.count("S")
mx = max(v["R"], v["P"], v["S"])
for n in v:
if v[n] == mx:
print(d[n] * len(s))
break
|
ASSIGN VAR DICT ASSIGN VAR STRING STRING ASSIGN VAR STRING STRING ASSIGN VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING FUNC_CALL VAR STRING ASSIGN VAR STRING FUNC_CALL VAR STRING ASSIGN VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING VAR STRING VAR STRING FOR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for t in range(int(input())):
s = input()
arr = [0] * 3
for i in s:
if i == "R":
arr[0] += 1
elif i == "P":
arr[1] += 1
else:
arr[2] += 1
ind = arr.index(max(arr))
if ind == 0:
v = "P"
elif ind == 1:
v = "S"
else:
v = "R"
print(v * len(s))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
w = {"R": "P", "S": "R", "P": "S"}
for c in range(t):
s = input()
count = {"R": 0, "S": 0, "P": 0}
for x in s:
count[x] += 1
print(w[max(count, key=lambda key: count[key])] * len(s))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
from sys import *
input = stdin.readline
t = int(input())
for _ in range(t):
st = input()
n = len(st)
r = 0
p = 0
s = 0
for i in st:
if i == "R":
r += 1
elif i == "S":
s += 1
elif i == "P":
p += 1
m = max(r, p, s)
n -= 1
if m == r:
res = "P" * n
elif m == s:
res = "R" * n
elif m == p:
res = "S" * n
print(res)
|
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for i in range(t):
inputstr = input()
output = ""
count = {}
for i in inputstr:
if i not in count:
count[i] = 1
else:
count[i] += 1
dict2 = {"R": "P", "P": "S", "S": "R"}
output = dict2[max(count, key=lambda i: count[i])] * len(inputstr)
print(output)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda: int(input().strip("\n"))
si = lambda: input().strip("\n")
dgl = lambda: list(map(int, input().strip("\n")))
f = lambda: map(int, input().strip("\n").split())
il = lambda: list(map(int, input().strip("\n").split()))
ls = lambda: list(input().strip("\n"))
lsc = lambda: list(input().strip("\n").split(" "))
lsi = lambda: [int(i) for i in ls()]
let = "abcdefghijklmnopqrstuvwxyz"
for _ in range(ii()):
s = si()
n = len(s)
rc = s.count("R")
sc = s.count("S")
pc = s.count("P")
x = max(rc, pc, sc)
if x == rc:
print("P" * n)
elif x == pc:
print("S" * n)
else:
print("R" * n)
|
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
T = int(input())
t = "RPSR"
for _ in range(T):
a = input()
l = []
for i in range(3):
l.append([a.count(t[i]), t[i + 1]])
print(max(l)[1] * len(a))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
si = input()
r = s = p = 0
n = len(si)
for i in si:
if i == "S":
s += 1
elif i == "R":
r += 1
else:
p += 1
m = max(s, p, r)
l = [("S", "R"), ("R", "P"), ("P", "S")]
if m == s:
print(n * "R")
elif m == p:
print(n * "S")
else:
print(n * "P")
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR STRING
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
for _ in range(int(input())):
l = list(input())
d = {"R": 0, "S": 0, "P": 0}
for i in l:
d[i] += 1
mw = None
n = None
for i in d:
if n is None or n < d[i]:
n = d[i]
mw = i
op = {"R": "P", "P": "S", "S": "R"}
print(op[mw] * len(l))
|
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR VAR IF VAR NONE VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
from sys import stdin
TT = int(stdin.readline())
alp = "RPS"
dic = {}
dic["R"] = 0
dic["P"] = 1
dic["S"] = 2
for loop in range(TT):
s = stdin.readline()[:-1]
lis = [0, 0, 0]
for i in s:
lis[dic[i]] += 1
maxind = 0
for i in range(3):
if lis[i] > lis[maxind]:
maxind = i
print(alp[(maxind + 1) % 3] * len(s))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR
|
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \dots s_{n}$ of length $n$ where each letter is either R, S or P.
While initializing, the bot is choosing a starting index $pos$ ($1 \le pos \le n$), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of $s_{pos}$: if $s_{pos}$ is equal to R the bot chooses "Rock"; if $s_{pos}$ is equal to S the bot chooses "Scissors"; if $s_{pos}$ is equal to P the bot chooses "Paper";
In the second round, the bot's choice is based on the value of $s_{pos + 1}$. In the third round — on $s_{pos + 2}$ and so on. After $s_n$ the bot returns to $s_1$ and continues his game.
You plan to play $n$ rounds and you've already figured out the string $s$ but still don't know what is the starting index $pos$. But since the bot's tactic is so boring, you've decided to find $n$ choices to each round to maximize the average number of wins.
In other words, let's suggest your choices are $c_1 c_2 \dots c_n$ and if the bot starts from index $pos$ then you'll win in $win(pos)$ rounds. Find $c_1 c_2 \dots c_n$ such that $\frac{win(1) + win(2) + \dots + win(n)}{n}$ is maximum possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains string $s = s_1 s_2 \dots s_{n}$ ($1 \le n \le 2 \cdot 10^5$; $s_i \in \{\text{R}, \text{S}, \text{P}\}$) — the string of the bot.
It's guaranteed that the total length of all strings in one test doesn't exceed $2 \cdot 10^5$.
-----Output-----
For each test case, print $n$ choices $c_1 c_2 \dots c_n$ to maximize the average number of wins. Print them in the same manner as the string $s$.
If there are multiple optimal answers, print any of them.
-----Example-----
Input
3
RRRR
RSP
S
Output
PPPP
RSP
R
-----Note-----
In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all $n = 4$ rounds, so the average is also equal to $4$.
In the second test case: if bot will start from $pos = 1$, then $(s_1, c_1)$ is draw, $(s_2, c_2)$ is draw and $(s_3, c_3)$ is draw, so $win(1) = 0$; if bot will start from $pos = 2$, then $(s_2, c_1)$ is win, $(s_3, c_2)$ is win and $(s_1, c_3)$ is win, so $win(2) = 3$; if bot will start from $pos = 3$, then $(s_3, c_1)$ is lose, $(s_1, c_2)$ is lose and $(s_2, c_3)$ is lose, so $win(3) = 0$; The average is equal to $\frac{0 + 3 + 0}{3} = 1$ and it can be proven that it's the maximum possible average.
A picture from Wikipedia explaining "Rock paper scissors" game: $\beta$
|
t = int(input())
for _ in range(t):
a, b, c = 0, 0, 0
for x in input():
if x == "P":
a += 1
elif x == "R":
b += 1
else:
c += 1
if a == max(a, b, c):
print("S" * (a + b + c))
elif b == max(a, b, c):
print("P" * (a + b + c))
else:
print("R" * (a + b + c))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP VAR VAR VAR
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.