結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-20 22:14:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 595 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 81,956 KB |
| 実行使用メモリ | 328,000 KB |
| 最終ジャッジ日時 | 2025-06-20 22:14:33 |
| 合計ジャッジ時間 | 3,261 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 20 |
ソースコード
from collections import deque
N=int(input())
P=deque(list(map(int,input().split())))
def is_ok():
ok=1
for i in range(N-1):
if P[i]+1!=P[i+1]:
ok=0;break
return ok
ans=[]
if is_ok():exit(print("".join(ans)))
while 1:
while P[0]+1==P[1] or P[0]-1==P[-1]:
ans.append("R");p=P.popleft();P.append(p)
if is_ok():exit(print("".join(ans)))
if P[0]-1==P[1]:
ans.append("S");P[0],P[1]=P[1],P[0]
else:
ans.append("R");p=P.popleft();P.append(p)
ans.append("S");P[0],P[1]=P[1],P[0]
if is_ok():exit(print("".join(ans)))