QOJ.ac

QOJ

Süre Sınırı: 1.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓

#17957. 剪刀石頭布氣泡排序

İstatistikler

Yihwan 是一位喜歡剪刀石頭布的 5 歲天才。他想獨自在家玩剪刀石頭布,於是發揮創意,用一些卡片製作了一個遊戲。

Yihwan 在位置 $1,2,\ldots,N$ 上放置 $N$ 張卡片,每張卡片上畫有剪刀、石頭或布。接著,按照 $i=1,2,\ldots,N-1$ 的遞增順序,若位置 $i$ 上的卡片能打敗位置 $i+1$ 上的卡片,就交換這兩張卡片。由於遊戲過程類似氣泡排序,Yihwan 將它命名為「剪刀石頭布氣泡排序」。卡片之間的勝負關係如下:

  • 剪刀卡片打敗布卡片。

  • 布卡片打敗石頭卡片。

  • 石頭卡片打敗剪刀卡片。

problem_17957_58a3d8a2108c15a99c0b9d48cf0e6e44.png

Yihwan 很擅長計算,因此玩了 $T$ 次這個遊戲後就去睡覺。然而,在他睡覺時,卡片意外被打亂了。幸好,Yihwan 是個記憶力極佳的天才,還記得遊戲開始前卡片的初始排列。不過,他不記得玩了 $T$ 次後卡片的最終排列,現在需要你的幫助。

請幫助 Yihwan 還原玩了 $T$ 次遊戲後卡片的最終排列。

輸入格式

第一行包含兩個整數,分別表示卡片數量 $N$($2\le N\le500\,000$)及 Yihwan 玩遊戲的次數 $T$($1\le T\le1\,000\,000\,000$)。

第二行包含一個長度為 $N$ 的字串。第 $i$ 個字元表示位置 $i$ 上卡片的種類。石頭卡片為 R,剪刀卡片為 S,布卡片為 P。

輸出格式

輸出玩了 $T$ 次遊戲後,長度為 $N$ 的字串。

範例

輸入格式 1

5 1
RSPSP

輸出格式 1

SRPPS

輸入格式 2

10 3
RSRRRRRRSR

輸出格式 2

SRRRRSRRRR

Discussions

About Discussions

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

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

Open Discussions 0
No discussions in this category.

Issues

About Issues

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

Guidelines:

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