結果

問題 No.1766 Tatsujin Remix
ユーザー first_vilfirst_vil
提出日時 2021-10-21 20:57:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 9,648 KB
最終ジャッジ日時 2023-09-12 04:45:16
合計ジャッジ時間 7,284 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,772 KB
testcase_01 AC 15 ms
7,796 KB
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 16 ms
7,844 KB
testcase_04 AC 24 ms
7,820 KB
testcase_05 AC 20 ms
7,828 KB
testcase_06 AC 32 ms
8,308 KB
testcase_07 AC 25 ms
7,852 KB
testcase_08 AC 19 ms
7,912 KB
testcase_09 AC 229 ms
9,160 KB
testcase_10 AC 222 ms
8,976 KB
testcase_11 AC 231 ms
9,032 KB
testcase_12 AC 234 ms
9,148 KB
testcase_13 AC 274 ms
9,248 KB
testcase_14 AC 376 ms
9,480 KB
testcase_15 AC 374 ms
9,576 KB
testcase_16 AC 378 ms
9,452 KB
testcase_17 AC 381 ms
9,636 KB
testcase_18 AC 378 ms
9,580 KB
testcase_19 AC 381 ms
9,484 KB
testcase_20 AC 374 ms
9,612 KB
testcase_21 AC 376 ms
9,576 KB
testcase_22 AC 377 ms
9,484 KB
testcase_23 AC 378 ms
9,648 KB
testcase_24 AC 346 ms
9,452 KB
testcase_25 AC 458 ms
9,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

n = int(input())
s = ''.join([input() for i in range(n)])+'.'

notes = ".dk";
dp = [1,0,0]
for i in range(16*n):
    for j in range(3):
        dp[j] %= mod
    nxt = [0]*3
    if s[i] == '.':
        nxt[0] += dp[0]
        if i % 2 == 1:
            nxt[0] += dp[1] + dp[2]
        
        if s[i + 1] != 'd':
            if i % 2 == 0:
                nxt[1] += dp[0]
            nxt[1] += dp[1] + dp[2]
            
        if s[i + 1] != 'k':
            if i % 2 == 0:
                nxt[2] += dp[0]
            nxt[2] += dp[1] + dp[2]
    else:
      if i % 2 == 0:
          nxt[notes.index(s[i])] += dp[0]
      nxt[notes.index(s[i])] += dp[1] + dp[2]
    dp = nxt
print(sum(dp) % mod)
0