結果

問題 No.1766 Tatsujin Remix
ユーザー tamatotamato
提出日時 2021-11-26 22:51:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,412 KB
実行使用メモリ 80,640 KB
最終ジャッジ日時 2023-09-12 05:20:41
合計ジャッジ時間 4,044 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,692 KB
testcase_01 AC 78 ms
71,744 KB
testcase_02 AC 77 ms
71,752 KB
testcase_03 AC 79 ms
71,612 KB
testcase_04 AC 88 ms
76,272 KB
testcase_05 AC 87 ms
76,392 KB
testcase_06 AC 91 ms
76,356 KB
testcase_07 AC 86 ms
76,092 KB
testcase_08 AC 81 ms
76,080 KB
testcase_09 AC 103 ms
79,004 KB
testcase_10 AC 100 ms
79,224 KB
testcase_11 AC 103 ms
79,016 KB
testcase_12 AC 105 ms
79,272 KB
testcase_13 AC 104 ms
79,412 KB
testcase_14 AC 106 ms
80,640 KB
testcase_15 AC 104 ms
80,516 KB
testcase_16 AC 106 ms
80,340 KB
testcase_17 AC 106 ms
80,508 KB
testcase_18 AC 104 ms
80,328 KB
testcase_19 AC 103 ms
80,372 KB
testcase_20 AC 104 ms
80,404 KB
testcase_21 AC 104 ms
80,604 KB
testcase_22 AC 107 ms
80,536 KB
testcase_23 AC 109 ms
80,408 KB
testcase_24 AC 94 ms
80,308 KB
testcase_25 AC 97 ms
80,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    S = []
    for _ in range(N):
        S.append(input().rstrip('\n'))
    S = "".join(S)
    N *= 16
    dp0 = [0] * (N+1)
    dp1 = [0] * (N+1)
    dp0[0] = 1
    for i, s in enumerate(S):
        if s == ".":
            if i & 1:
                dp0[i+1] = (dp0[i] + dp1[i])%mod
                if i+1 < N:
                    if S[i+1] == ".":
                        dp1[i + 1] = ((0 + dp1[i]) % mod * 2)%mod
                    else:
                        dp1[i+1] = (0 + dp1[i])%mod
                else:
                    dp1[i + 1] = ((0 + dp1[i]) % mod * 2) % mod
            else:
                dp0[i+1] = dp0[i]
                if i+1 < N:
                    if S[i+1] == ".":
                        dp1[i + 1] = ((dp0[i] + dp1[i]) % mod * 2)%mod
                    else:
                        dp1[i+1] = (dp0[i] + dp1[i])%mod
                else:
                    dp1[i + 1] = ((dp0[i] + dp1[i]) % mod * 2) % mod
        else:
            if i & 1 == 0:
                dp1[i+1] = (dp0[i] + dp1[i])%mod
            else:
                dp1[i+1] = dp1[i]
    print((dp0[-1] + dp1[-1])%mod)


if __name__ == '__main__':
    main()
0