結果

問題 No.1766 Tatsujin Remix
ユーザー mkawa2mkawa2
提出日時 2021-11-27 12:33:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,525 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 89,584 KB
最終ジャッジ日時 2023-09-12 15:36:37
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,248 KB
testcase_01 AC 72 ms
71,264 KB
testcase_02 AC 72 ms
71,436 KB
testcase_03 AC 72 ms
71,268 KB
testcase_04 AC 124 ms
77,720 KB
testcase_05 AC 108 ms
77,468 KB
testcase_06 AC 121 ms
77,628 KB
testcase_07 AC 116 ms
77,784 KB
testcase_08 AC 97 ms
76,792 KB
testcase_09 AC 157 ms
82,600 KB
testcase_10 AC 157 ms
82,496 KB
testcase_11 AC 162 ms
82,612 KB
testcase_12 AC 161 ms
82,600 KB
testcase_13 AC 159 ms
84,552 KB
testcase_14 AC 173 ms
89,064 KB
testcase_15 AC 173 ms
89,516 KB
testcase_16 AC 174 ms
89,308 KB
testcase_17 AC 173 ms
89,432 KB
testcase_18 AC 173 ms
89,536 KB
testcase_19 AC 179 ms
89,584 KB
testcase_20 AC 172 ms
89,216 KB
testcase_21 AC 178 ms
89,388 KB
testcase_22 AC 176 ms
89,552 KB
testcase_23 AC 176 ms
89,412 KB
testcase_24 AC 123 ms
89,140 KB
testcase_25 AC 172 ms
89,488 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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
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 = 18446744073709551615
# inf = 4294967295
# md = 10**9+7
md = 998244353

n = II()
aa = []
for _ in range(n):
    aa += [".dk".find(c) for c in SI()]
n *= 16
# print(aa)

dp = [0]*3
a = aa[0]
if a == 0:
    dp[0] = 1
    if n > 1 and aa[1] > 0:
        dp[3-aa[1]] = 1
    else:
        dp[1] = 1
        dp[2] = 1
else:
    dp[a] = 1

for i, a in enumerate(aa[1:], 1):
    ndp = [0]*3
    for j in range(3):
        if dp[j] == 0: continue
        if a == 0:
            for nj in range(3):
                if i & 1 == 0 and j > 0 and nj == 0: continue
                if i & 1 and j == 0 and nj > 0: continue
                if i+1 < n and a == 0 and aa[i+1] > 0 and nj == aa[i+1]: continue
                ndp[nj] += dp[j]
        if i & 1 and j == 0: continue
        if a == 1:
            ndp[a] += dp[j]
        if a == 2:
            ndp[a] += dp[j]
    for j in range(3): ndp[j] %= md
    dp = ndp
    # print(i, a, dp)

print(sum(dp)%md)
0