結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 16 ms
7,840 KB
testcase_02 AC 16 ms
7,808 KB
testcase_03 AC 16 ms
7,792 KB
testcase_04 AC 24 ms
7,808 KB
testcase_05 AC 22 ms
7,800 KB
testcase_06 AC 31 ms
8,340 KB
testcase_07 AC 25 ms
7,816 KB
testcase_08 AC 19 ms
7,792 KB
testcase_09 AC 218 ms
9,080 KB
testcase_10 AC 220 ms
9,160 KB
testcase_11 AC 222 ms
9,052 KB
testcase_12 AC 228 ms
9,076 KB
testcase_13 AC 265 ms
9,128 KB
testcase_14 AC 370 ms
9,496 KB
testcase_15 AC 356 ms
9,472 KB
testcase_16 AC 369 ms
9,452 KB
testcase_17 AC 363 ms
9,448 KB
testcase_18 AC 363 ms
9,580 KB
testcase_19 AC 361 ms
9,604 KB
testcase_20 AC 362 ms
9,596 KB
testcase_21 AC 368 ms
9,472 KB
testcase_22 AC 375 ms
9,548 KB
testcase_23 AC 373 ms
9,620 KB
testcase_24 AC 334 ms
9,600 KB
testcase_25 AC 439 ms
9,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
mod = 998244353

n = int(input())
s = ''.join([input().rstrip() 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