結果
| 問題 | No.2541 Divide 01 String | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-11-24 21:27:00 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 22 ms / 2,000 ms | 
| コード長 | 593 bytes | 
| コンパイル時間 | 1,943 ms | 
| コンパイル使用メモリ | 199,864 KB | 
| 最終ジャッジ日時 | 2025-02-17 23:42:41 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string s; cin >> s;
    vector dp(N+1,vector<long long>(2));
    dp.at(0).at(0) = 1;
    long long mod = 998244353;
    for(int i=0; i<N; i++) for(int k=0; k<2; k++){
        if(k == 1) dp.at(i+1).at(1) = (dp.at(i+1).at(1)+dp.at(i).at(k))%mod;
        if(s.at(i) == '1') dp.at(i+1).at(1) = (dp.at(i+1).at(1)+dp.at(i).at(k))%mod;
        else dp.at(i+1).at(0) = (dp.at(i+1).at(0)+dp.at(i).at(k))%mod;
    }    
    cout << dp.at(N).at(1) << endl;
}
            
            
            
        