結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-06-20 22:06:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 1,000 ms |
| コード長 | 579 bytes |
| コンパイル時間 | 269 ms |
| コンパイル使用メモリ | 82,404 KB |
| 実行使用メモリ | 71,468 KB |
| 最終ジャッジ日時 | 2025-06-20 22:06:29 |
| 合計ジャッジ時間 | 2,636 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
from collections import deque
N = int(input())
P = list(map(int, input().split()))
def is_sorted(q):
xs = list(q)
for i in range(len(xs)):
if xs[i] != i:
return False
return True
q = deque(P)
ans = []
for i in reversed(range(N-1)):
while 1:
if q[0] == i:
if q[1] == i+1:
break
ans.append('S')
q[0], q[1] = q[1], q[0]
ans.append('R')
q.append(q.popleft())
else:
ans.append('R')
q.append(q.popleft())
print(*ans, sep='')
norioc