結果

問題 No.3183 Swap or Rotate
ユーザー hato336
提出日時 2025-06-20 21:36:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 628 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 82,744 KB
実行使用メモリ 454,452 KB
最終ジャッジ日時 2025-06-20 21:36:11
合計ジャッジ時間 5,299 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1 -- * 2
other -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))

ans = []
for i in range(2,n+1):
    while a[0] != i:
        ans.append('R')
        a.append(a.pop(0))
    ans.append('S')
    a[0],a[1] = a[1],a[0]
    while a[0] != i-1:
        ans.append('R')
        a.append(a.pop(0))
        ans.append('S')
        a[0],a[1] = a[1],a[0]
        

while a != list(range(1,n+1)):
    ans.append('R')
    a.append(a.pop(0))

print(''.join(ans))

    
0