結果

問題 No.3183 Swap or Rotate
ユーザー tkykwtnb
提出日時 2025-06-20 22:05:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 533 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 350,348 KB
最終ジャッジ日時 2025-06-20 22:05:55
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N=int(input())
P=deque(list(map(int,input().split())))
def is_ok():
    ok=1
    for i in range(N-1):
        if P[i]+1!=P[i+1]:
            ok=0;break
    return ok
ans=[]
while not is_ok():
    while P[0]+1==P[1]:
        ans.append("R")
        p=P.popleft()
        P.append(p)
    if P[0]-1==P[1]:
        ans.append("S")
        P[0],P[1]=P[1],P[0]
    else:
        ans.append("R")
        p=P.popleft()
        P.append(p)
        ans.append("S")
        P[0],P[1]=P[1],P[0]
print("".join(ans))
0