結果

問題 No.3183 Swap or Rotate
コンテスト
ユーザー titia
提出日時 2025-06-20 21:36:40
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 73 ms / 1,000 ms
+ 703µs
コード長 529 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 95,848 KB
実行使用メモリ 83,644 KB
最終ジャッジ日時 2026-07-12 14:57:26
合計ジャッジ時間 3,534 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

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

ANS=[]

for i in range(1,N):
    x=P.index(i)
    y=P.index(i-1)

    if x==(y+1)%N:
        continue

    while True:
        x=P.index(i)
        y=P.index(i-1)

        if x==(y+1)%N:
            break

        if P[0]==i:
            ANS.append("S")
            P[0],P[1]=P[1],P[0]
            continue
        else:
            ANS.append("R")
            P=P[1:]+[P[0]]

#print(P)
        
x=P.index(0)
ANS+="R"*x

print("".join(ANS))
0