結果
| 問題 | No.2541 Divide 01 String | 
| コンテスト | |
| ユーザー |  鴨志田卓 | 
| 提出日時 | 2024-01-11 15:37:25 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 445 bytes | 
| コンパイル時間 | 2,016 ms | 
| コンパイル使用メモリ | 194,480 KB | 
| 最終ジャッジ日時 | 2025-02-18 17:14:20 | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector<int> p;
    for(int i = 0; i < n; i ++)
        if(s[i] == '1') p.push_back(i);
    
    if(p.empty()) cout << "0";
    else{
        int ans = 1;
        for(int i = 1; i < p.size(); i ++)
            ans = ans * (p[i] - p[i - 1] + 1ll) % 998244353;
        cout << ans;
    }
}
            
            
            
        