結果

問題 No.1650 Moving Coins
ユーザー mkawa2mkawa2
提出日時 2021-08-20 21:57:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,327 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 86,080 KB
最終ジャッジ日時 2024-04-22 04:28:36
合計ジャッジ時間 16,584 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 326 ms
24,448 KB
testcase_04 AC 258 ms
21,248 KB
testcase_05 AC 306 ms
23,424 KB
testcase_06 AC 330 ms
24,832 KB
testcase_07 AC 337 ms
25,088 KB
testcase_08 AC 603 ms
55,468 KB
testcase_09 AC 592 ms
58,100 KB
testcase_10 AC 648 ms
58,436 KB
testcase_11 AC 645 ms
59,948 KB
testcase_12 AC 513 ms
47,608 KB
testcase_13 RE -
testcase_14 AC 598 ms
57,736 KB
testcase_15 AC 472 ms
43,392 KB
testcase_16 AC 682 ms
60,412 KB
testcase_17 AC 660 ms
62,420 KB
testcase_18 AC 724 ms
65,376 KB
testcase_19 AC 883 ms
86,080 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 864 ms
73,560 KB
testcase_23 AC 860 ms
73,560 KB
testcase_24 AC 335 ms
25,216 KB
testcase_25 AC 333 ms
25,216 KB
testcase_26 AC 465 ms
53,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**9
md = 998244353
# md = 10**9+7

n = II()
aa = LI()
bb = LI()

dd = [0]*n
for i, (a, b) in enumerate(zip(aa, bb)):
    dd[i] = b-a

to = [[] for _ in range(n)]
for i in range(n-1):
    if dd[i] > 0 and dd[i+1] > 0: to[i+1].append(i)
    if dd[i] < 0 and dd[i+1] < 0: to[i].append(i+1)

def dfs(i):
    fin[i] = True
    for j in to[i]:
        if fin[j]: continue
        dfs(j)
    topo.append(i)

topo = []
fin = [False]*n
for i in range(n):
    if fin[i]: continue
    dfs(i)

ans = []
for i in topo[::-1]:
    if dd[i] == 0: continue
    if dd[i] > 0:
        for _ in range(dd[i]):
            ans.append((i+1, "R"))
    else:
        for _ in range(-dd[i]):
            ans.append((i+1, "L"))

print(len(ans))
for i, c in ans: print(i, c)
0