結果

問題 No.3500 01 String
コンテスト
ユーザー dayo ZOI
提出日時 2026-04-18 17:27:08
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 663 ms / 2,000 ms
コード長 1,188 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,541 ms
コンパイル使用メモリ 147,632 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-18 17:27:18
合計ジャッジ時間 5,857 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <string>
#include <iostream>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0; i<n; ++i)

const ll mod = 998244353;

ll powm(ll x, ll n) {
    ll res = 1;
    while(n) {
        if(n & 1) {
            res *= x;
            res %= mod;
        }
        n >>= 1;
        x *= x;
        x %= mod;
    }
    return res;
}

int main() {
    ll n;
    string a;
    cin >> n >> a;
    ll w = 0, b = 0;
    ll res = 1;
    ll i = 0;
    while(i < n) {
        while(i < n && a[i] == '0') {
            w++;
            i++;
        }
        while(i < n && a[i] == '1') {
            b++;
            i++;
        }
        if(w > 0 && b > 0) {
            res *= (w + b + 1);
            res %= mod;
        }
        cerr << w << " " << b << endl;
        w = b = 0;
    }
    cout << res << endl;
    // ll m = 0;
    // rep(i, n-1) {
    //     if(a[i] == '0' && a[i+1] == '1') m++;
    // }
    // // n+m C m

    // vector<ll> power(1'000'000, 1);
    // for(int i=1; i<1'000'000; i++) {
    //     power[i] = power[i-1] * i;
    //     power[i] %= mod;
    // }

    // cout << power[n+m] * powm(power[m] * power[n] % mod, mod-2) % mod << endl;
    
}
0