結果

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

ソースコード

diff #
raw source code

// @yuuzaa_tkms
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define Ye cout<<"Yes"<<endl
#define YE cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vec vector
using namespace std;
using ll=long long;
using ull=unsigned long long;
using namespace atcoder;
using mint=modint998244353;
vector<int>dx={0,1,0,-1,-1,-1,1,1};
vector<int>dy={1,0,-1,0,-1,1,-1,1};
int INF=1e9;
ull LINF=1e18;
bool edge(int x,int y,int H,int W){
    if(x<0||x>=H||y<0||y>=W)return 0;
    else return 1;
}
//実装は丁寧に書こう
//1400復帰しよう!
int main(){
    int N;
    cin>>N;
    string A;
    cin>>A;
    int now=0;
    bool z=0,o=0;
    mint ans=1;
    rep(i,N){
        now++;
        if(A[i]=='0')z=1;
        if(A[i]=='1')o=1;
        if(i!=N-1&&A[i]=='1'&&A[i+1]=='0'){
        	if(z&&o)ans*=now+1;
            now=0;
            z=0;
            o=0;
        }
    }
    if(z&&o)ans*=now+1;
    cout<<ans.val()<<endl;
}
0