結果
| 問題 | No.3183 Swap or Rotate |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-25 08:39:57 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 1,000 ms |
| + 241µs | |
| コード長 | 507 bytes |
| 記録 | |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 83,988 KB |
| 最終ジャッジ日時 | 2026-07-12 19:28:20 |
| 合計ジャッジ時間 | 3,456 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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))