結果

問題 No.2219 Re:010
ユーザー ぷら
提出日時 2023-02-17 21:27:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 192,312 KB
最終ジャッジ日時 2025-02-10 16:15:41
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mod = 998244353;

int dp[200200][4];

void mpl(int &x,int y) {
    x += y;
    if(x >= mod) x -= mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    dp[0][0] = 1;
    for(int i = 0; i < S.size(); i++) {
        for(int j = 0; j < 4; j++) {
            mpl(dp[i+1][j],dp[i][j]);
            if(S[i] == '0' && (j == 0 || j == 2)) {
                mpl(dp[i+1][j+1],dp[i][j]);
            }
            if(S[i] == '1' && j == 1) {
                mpl(dp[i+1][j+1],dp[i][j]);
            }
            if(S[i] == '?' && j < 3) {
                mpl(dp[i+1][j+1],dp[i][j]);
            }
            if(S[i] == '?') {
                mpl(dp[i+1][j],dp[i][j]);
            }
        }
    }
    cout << dp[S.size()][3] << "\n";
}
0