結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-06-20 21:36:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 1,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 306 ms |
| コンパイル使用メモリ | 82,288 KB |
| 実行使用メモリ | 76,192 KB |
| 最終ジャッジ日時 | 2025-06-20 21:36:53 |
| 合計ジャッジ時間 | 2,430 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
P=list(map(int,input().split()))
ANS=[]
for i in range(1,N):
x=P.index(i)
y=P.index(i-1)
if x==(y+1)%N:
continue
while True:
x=P.index(i)
y=P.index(i-1)
if x==(y+1)%N:
break
if P[0]==i:
ANS.append("S")
P[0],P[1]=P[1],P[0]
continue
else:
ANS.append("R")
P=P[1:]+[P[0]]
#print(P)
x=P.index(0)
ANS+="R"*x
print("".join(ANS))
titia