409922: GYM103855 E RPS Bubble Sort

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. RPS Bubble Sorttime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Yihwan is a 5-year-old genius who enjoys rock-paper-scissors. He wanted to play rock-paper-scissors alone at his house, so he showed his creativity and made a game using some cards.

Yihwan places $$$N$$$ cards, each with one of scissors, rock, or paper, on positions $$$1, 2, \ldots, N$$$. Then, for each of $$$i = 1, 2, \ldots, N - 1$$$ in increasing order, Yihwan swaps the card at positions $$$i$$$ and $$$i + 1$$$ if the card in the $$$i$$$-th position beats the card in the $$$i+1$$$-th position. As the process of the game is similar to bubble sort, Yihwan named this game 'Rock-paper-scissors Bubble Sort'. The win-lose relationship of the cards is as follows:

  • A card with scissors beats a card with paper.
  • A card with paper beats a card with rock.
  • A card with rock beats a card with scissors.

Yihwan is very good at calculating, so he played this game $$$T$$$ times and went to sleep. However, while Yihwan was sleeping, the cards were accidentally shuffled. Fortunately, since Yihwan is a genius with excellent memory, he remembered the arrangement of the initial cards before the game. However, he couldn't remember the final arrangement of cards after $$$T$$$ games and now needs your help.

Please help Yihwan by restoring the final arrangement of cards after playing the game $$$T$$$ times.

Input

The first line contains two integers denoting the number of cards $$$N$$$ ($$$ 2 \leq N \leq 500\,000 $$$) and the number of times $$$T$$$ ($$$1 \leq T \leq 1\,000\,000\,000$$$) Yihwan played the game.

The second line contains a string of length $$$N$$$. The $$$i$$$-th character indicates the type of card placed at the $$$i$$$-th position. A card with rock is R, a card with scissors is S, and a card with paper is P.

Output

Output the string of length $$$N$$$ after playing the game $$$T$$$ times.

ExamplesInput
5 1
RSPSP
Output
SRPPS
Input
10 3
RSRRRRRRSR
Output
SRRRRSRRRR

加入题单

上一题 下一题 算法标签: