結果

問題 No.1650 Moving Coins
ユーザー wolgnikwolgnik
提出日時 2021-08-20 21:56:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 271,304 KB
最終ジャッジ日時 2024-04-22 04:27:29
合計ジャッジ時間 5,538 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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