結果

問題 No.3500 01 String
コンテスト
ユーザー Takenokomeshi
提出日時 2026-10-10 17:03:07
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,597 ms
コンパイル使用メモリ 435,512 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-10 17:03:17
合計ジャッジ時間 8,297 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 3 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//謎の呪文
#ifdef ONLINE_JUDGE
//あとこだ
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#else
//手元
#endif

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vb=vector<bool>;
template<class T>using ve=vector<T>;
template<class T,ll num>using ar=array<T,num>;
template<class T>using pq=priority_queue<T, vector<T>>;
template<class T>using pq_g=priority_queue<T, vector<T>, greater<T>>;
#define print(a) cout<<a<<'\n'
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define drep(i,a,b) for(ll i=(a);i>(b);i--)
#define all(v) v.begin(),v.end()
#define dall(v) v.rbegin(),v.rend()
#define pyes print("Yes")
#define pno print("No")
template<class T>istream&operator>>(istream&i,vector<T>&v){rep(j,0,(ll)size(v))i>>v[j];return i;}
template<class T,size_t N>istream&operator>>(istream&i,array<T,N>&v){rep(j,0,(ll)N)i>>v[j];return i;}
//ほんへ
using mint=modint998244353;
int main(){
    //呪い
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //やれ
    ll n;
    string a;
    cin>>n>>a;
    ar<mint,2>now;
    if(a[0]=='1')now={0,1};
    else now={1,1};
    rep(i,1,n){
        ar<mint,2>nxt;
        if(a[i-1]=='0'&&a[i]=='1'){
            nxt={now[0],now[0]+now[1]};
        }
        else if(a[i-1]=='1'&&a[i]=='0'){
            nxt={now[0]+now[1],now[1]};
        }
        else{
            nxt=now;
        }
        swap(now,nxt);
    }
    print(now[0].val()+now[1].val());
}
//cp template.cpp a.cpp
0