結果

問題 No.3183 Swap or Rotate
ユーザー shogo314
提出日時 2025-06-20 21:27:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 1,000 ms
コード長 565 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 76,320 KB
最終ジャッジ日時 2025-06-20 21:27:52
合計ジャッジ時間 2,465 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int, input().split()))
ans = []
while True:
    z = P.index(0)
    t = None
    for i in range(N - 1):
        if i == z or i + 1 == z:
            continue
        if P[i] > P[i + 1]:
            t = i
            break
    if t is None:
        if z == 0:
            break
        else:
            ans.append("R")
            P = P[1:] + [P[0]]
    else:
        if t == 0:
            ans.append("S")
            P[0], P[1] = P[1], P[0]
        else:
            ans.append("R")
            P = P[1:] + [P[0]]
print("".join(ans))
0