結果

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

ソースコード

diff #

n,*P = map(int,open(0).read().split())
Q = P.copy()
s = sum(P[i]>P[j] for i in range(n) for j in range(i+1,n))
i = 0
ans = []
for _ in range(s):
  while P[i]<P[i+1]:
    i = (i+1)%n
    ans.append('R')
    if i==n-1:
      i = (i+1)%n
      ans.append('R')
  P[i],P[i+1] = P[i+1],P[i]
  ans.append('S')
while i:
  i = (i+1)%n
  ans.append('R')
print(''.join(ans))
0