結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-25 08:39:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 1,000 ms |
| コード長 | 507 bytes |
| コンパイル時間 | 558 ms |
| コンパイル使用メモリ | 82,908 KB |
| 実行使用メモリ | 66,692 KB |
| 最終ジャッジ日時 | 2025-06-25 08:40:01 |
| 合計ジャッジ時間 | 3,407 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
from collections import deque
N = int(input())
P = deque(list(map(int,input().split())))
ans = []
for i in range(N-2,0,-1):
ind = P.index(i)
if P[(ind+1)%N]==i+1:continue
while True:
while P[0]!=i:
a = P.popleft()
P.append(a)
ans.append("R")
P[0],P[1] = P[1],P[0]
ans.append("S")
if P[2]==i+1:break
if P!=list(range(N)):
while P[0]!=0:
a = P.popleft()
P.append(a)
ans.append("R")
print("".join(ans))