結果
| 問題 | No.2219 Re:010 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-02-17 21:46:18 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 9 ms / 2,000 ms | 
| コード長 | 692 bytes | 
| コンパイル時間 | 1,756 ms | 
| コンパイル使用メモリ | 171,744 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 12:56:47 | 
| 合計ジャッジ時間 | 2,464 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    vector<mint> dp(4);
    dp[3] = 1;
    for (char c : s) {
        vector<mint> nxt(4);
        if (c != '1') {
            nxt[0] += dp[0] + dp[3];
            nxt[1] += dp[1];
            nxt[2] += dp[2] + dp[1];
            nxt[3] += dp[3];
        }
        if (c != '0') {
            nxt[0] += dp[0];
            nxt[1] += dp[1] + dp[0];
            nxt[2] += dp[2];
            nxt[3] += dp[3];
        }
        dp = nxt;
    }
    cout << dp[2].val();
}
            
            
            
        