提出 #19695264
ソースコード 拡げる
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import numpy as np
H, W, K = map(int, input().split())
MOD = 998244353
cells = {}
for _ in range(K):
h, w, c = input().split()
h, w = int(h) - 1, int(w) - 1
cells[(h, w)] = c
# dp[h][w][k] := ロボットが(0, 0)から出発して空白マスをk箇所通って(h - 1, w - 1)に到達するような経路の個数
dp = np.zeros((H + W + 1, H + 1, W + 1), dtype='i')
dp[0, 0, 0] = 1
# 配るDP
for h in range(H):
for w in range(W):
v = cells.get((h, w), None)
for k in range(H + W):
if v is None:
dp[k + 1, h + 1, w] += dp[k, h, w]
dp[k + 1, h, w + 1] += dp[k, h, w]
if v in ['D', 'X']:
dp[k, h + 1, w] += dp[k, h, w]
if v in ['R', 'X']:
dp[k, h, w + 1] += dp[k, h, w]
ans = 0
for k in range(H + W + 1):
ans += dp[k, H - 1, W - 1] * pow(2, k, MOD) * pow(3, H * W - K - k)
ans %= MOD
print(int(ans))
提出情報
ジャッジ結果
セット名 |
Sample |
All |
得点 / 配点 |
0 / 0 |
0 / 500 |
結果 |
|
AC |
× 6 |
WA |
× 1 |
TLE |
× 4 |
RE |
× 10 |
|
セット名 |
テストケース |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, sample_01.txt, sample_02.txt, sample_03.txt |
ケース名 |
結果 |
実行時間 |
メモリ |
random_01.txt |
TLE |
3310 ms |
60572 KB |
random_02.txt |
TLE |
3310 ms |
60352 KB |
random_03.txt |
TLE |
3311 ms |
84228 KB |
random_04.txt |
TLE |
3311 ms |
84380 KB |
random_05.txt |
RE |
531 ms |
63664 KB |
random_06.txt |
RE |
536 ms |
63636 KB |
random_07.txt |
RE |
535 ms |
63524 KB |
random_08.txt |
RE |
543 ms |
63536 KB |
random_09.txt |
RE |
543 ms |
63548 KB |
random_10.txt |
RE |
538 ms |
63504 KB |
random_11.txt |
WA |
325 ms |
27784 KB |
random_12.txt |
AC |
223 ms |
27216 KB |
random_13.txt |
AC |
198 ms |
27084 KB |
random_14.txt |
AC |
258 ms |
27332 KB |
random_15.txt |
AC |
201 ms |
27144 KB |
random_16.txt |
RE |
326 ms |
44424 KB |
random_17.txt |
RE |
372 ms |
46616 KB |
random_18.txt |
RE |
125 ms |
26592 KB |
sample_01.txt |
AC |
125 ms |
27204 KB |
sample_02.txt |
AC |
121 ms |
26996 KB |
sample_03.txt |
RE |
119 ms |
26908 KB |