結果

問題 No.3183 Swap or Rotate
ユーザー norioc
提出日時 2025-06-20 21:49:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 61,088 KB
最終ジャッジ日時 2025-06-20 21:49:25
合計ジャッジ時間 4,435 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N = int(input())
P = list(map(int, input().split()))


def is_sorted(q):
    xs = list(q)
    for i in range(len(xs)):
        if xs[i] != i:
            return False

    return True


q = deque(P)
ans = []
while 1:
    if len(ans) > 100: break
    if q[0] == 0 and is_sorted(q):
        break

    if q[0] < q[1]:
        ans.append('S')
        q[0], q[1] = q[1], q[0]
    else:
        ans.append('R')
        x = q.popleft()
        q.append(x)

print(*ans, sep='')
0