結果

問題 No.3183 Swap or Rotate
ユーザー zozu
提出日時 2025-07-01 01:27:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 1,256 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 74,928 KB
最終ジャッジ日時 2025-07-01 01:27:19
合計ジャッジ時間 3,511 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
from collections import deque
from collections import Counter
from collections import defaultdict
import bisect
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

def main():
    N = I()
    P = deque(LI())
    PP = deque([i for i in range(N)])
    def swap(D):
        D[0], D[1] = D[1], D[0]
        return D
    def shift(D):
        D.rotate(-1)
        return D
    ans = []
    for _ in range(15000):
        if P[0] > P[1]:
            if P[0] == N-1 and P[1] == 0:
                P = shift(P)
                ans.append('R')
            else:
                P = swap(P)
                ans.append('S')
        else:
            P = shift(P)
            ans.append('R')
        # print(P)
        if P == PP:
            print(''.join(ans))
            exit()

if __name__ == "__main__":
    main()
0