結果
問題 | No.1650 Moving Coins |
ユーザー | mkawa2 |
提出日時 | 2021-08-20 21:57:05 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,327 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 85,952 KB |
最終ジャッジ日時 | 2024-10-14 03:31:42 |
合計ジャッジ時間 | 16,308 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
11,008 KB |
testcase_01 | AC | 29 ms
11,008 KB |
testcase_02 | AC | 30 ms
10,752 KB |
testcase_03 | AC | 318 ms
24,448 KB |
testcase_04 | AC | 243 ms
21,120 KB |
testcase_05 | AC | 289 ms
23,424 KB |
testcase_06 | AC | 324 ms
24,832 KB |
testcase_07 | AC | 323 ms
24,960 KB |
testcase_08 | AC | 583 ms
55,484 KB |
testcase_09 | AC | 588 ms
57,824 KB |
testcase_10 | AC | 622 ms
58,176 KB |
testcase_11 | AC | 616 ms
60,088 KB |
testcase_12 | AC | 484 ms
47,732 KB |
testcase_13 | RE | - |
testcase_14 | AC | 586 ms
57,612 KB |
testcase_15 | AC | 459 ms
43,132 KB |
testcase_16 | AC | 661 ms
60,264 KB |
testcase_17 | AC | 638 ms
62,416 KB |
testcase_18 | AC | 703 ms
65,116 KB |
testcase_19 | AC | 862 ms
85,952 KB |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | AC | 822 ms
73,460 KB |
testcase_23 | AC | 832 ms
73,548 KB |
testcase_24 | AC | 324 ms
24,960 KB |
testcase_25 | AC | 330 ms
25,216 KB |
testcase_26 | AC | 444 ms
53,188 KB |
ソースコード
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)