結果

問題 No.1650 Moving Coins
ユーザー wolgnik
提出日時 2021-08-20 21:56:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 269,564 KB
最終ジャッジ日時 2024-10-14 03:30:34
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 5 TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a = [i for i in range(N)]
b = [i + 1 for i in range(N)]

res = []
s = {i for i in range(N)}
while len(s):
  t = set(s)
  for i in t:
    if a[i] < b[i]:
      if i + 1 < N and a[i + 1] == a[i] + 1:
        s.discard(i)
        continue
      res.append((i + 1, "R"))
      a[i] += 1
    elif a[i] > b[i]:
      if i and a[i - 1] == a[i] + 1:
        s.discard(i)
      res.append((i + 1, "L"))
      a[i] -= 1
    if a[i] == b[i]:
      if i + 1 < N and a[i + 1] != b[i + 1] and not (i + 1) in s: s.add(i + 1)
      if i and a[i - 1] != b[i - 1] and not (i - 1) in s: s.add(i - 1)
      s.discard(i)

print(len(res))
for r in res: print(*r)
0