結果

問題 No.1766 Tatsujin Remix
ユーザー first_vilfirst_vil
提出日時 2021-10-21 21:06:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 1,172 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 78,088 KB
最終ジャッジ日時 2023-09-12 04:44:52
合計ジャッジ時間 5,230 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,096 KB
testcase_01 AC 71 ms
71,224 KB
testcase_02 AC 71 ms
71,500 KB
testcase_03 AC 72 ms
71,096 KB
testcase_04 AC 87 ms
76,536 KB
testcase_05 AC 83 ms
76,688 KB
testcase_06 AC 93 ms
76,952 KB
testcase_07 AC 91 ms
76,764 KB
testcase_08 AC 83 ms
76,816 KB
testcase_09 AC 116 ms
77,712 KB
testcase_10 AC 117 ms
77,792 KB
testcase_11 AC 116 ms
77,684 KB
testcase_12 AC 114 ms
77,712 KB
testcase_13 AC 120 ms
77,872 KB
testcase_14 AC 125 ms
78,008 KB
testcase_15 AC 127 ms
77,936 KB
testcase_16 AC 125 ms
78,036 KB
testcase_17 AC 124 ms
77,700 KB
testcase_18 AC 123 ms
78,076 KB
testcase_19 AC 127 ms
77,968 KB
testcase_20 AC 125 ms
78,088 KB
testcase_21 AC 127 ms
77,960 KB
testcase_22 AC 122 ms
77,972 KB
testcase_23 AC 123 ms
77,756 KB
testcase_24 AC 110 ms
77,808 KB
testcase_25 AC 116 ms
77,976 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