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.