結果

問題 No.3183 Swap or Rotate
ユーザー Mitarushi
提出日時 2025-06-15 10:08:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 1,000 ms
コード長 402 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,644 KB
実行使用メモリ 62,240 KB
最終ジャッジ日時 2025-06-15 12:30:56
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
assert 2 <= n <= 100
p = list(map(int, input().split()))
assert len(p) == n
assert set(p) == set(range(n))

not_yet = True
ans = []
while not_yet:
    not_yet = False
    for i in range(n - 1):
        if p[i] > p[i + 1]:
            not_yet = True
            p[i], p[i + 1] = p[i + 1], p[i]
            ans.append('S')
        ans.append('R')
    ans.append('R')

print(''.join(ans))
0