結果

問題 No.2219 Re:010
ユーザー ntudantuda
提出日時 2023-02-19 16:06:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 98,988 KB
最終ジャッジ日時 2023-09-27 21:35:47
合計ジャッジ時間 4,186 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,148 KB
testcase_01 AC 63 ms
71,240 KB
testcase_02 AC 65 ms
71,444 KB
testcase_03 AC 141 ms
96,192 KB
testcase_04 AC 79 ms
76,584 KB
testcase_05 AC 113 ms
92,356 KB
testcase_06 AC 79 ms
76,640 KB
testcase_07 AC 99 ms
85,988 KB
testcase_08 AC 119 ms
94,884 KB
testcase_09 AC 118 ms
94,204 KB
testcase_10 AC 108 ms
89,996 KB
testcase_11 AC 104 ms
87,832 KB
testcase_12 AC 102 ms
88,084 KB
testcase_13 AC 131 ms
98,960 KB
testcase_14 AC 133 ms
98,844 KB
testcase_15 AC 132 ms
98,800 KB
testcase_16 AC 131 ms
98,676 KB
testcase_17 AC 133 ms
98,988 KB
testcase_18 AC 124 ms
98,764 KB
testcase_19 AC 122 ms
98,760 KB
testcase_20 AC 123 ms
98,788 KB
testcase_21 AC 66 ms
71,144 KB
testcase_22 AC 64 ms
71,308 KB
testcase_23 AC 64 ms
71,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
S = input()
N = len(S)
if N < 3:
    print(0)
    exit()

def solve():
    dp = [[0] * 4 for _ in range(N + 1)]
    dp[0][0] = 1
    
    for i in range(N):
        tmp = 0
        if S[i] == "0" or S[i] == "?":
            dp[i+1][1] += dp[i][0]
            dp[i+1][3] += dp[i][2]
            tmp += 1
        if S[i] == "1" or S[i] == "?":
            dp[i+1][2] += dp[i][1]
            tmp += 1
        for j in range(4):
            dp[i+1][j] += dp[i][j] * tmp
            dp[i+1][j] %= MOD
        #print(i,dp)
    return dp[N][3]

print(solve())
0