結果

問題 No.2219 Re:010
ユーザー otoshigootoshigo
提出日時 2023-02-17 23:42:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 202,196 KB
実行使用メモリ 6,660 KB
最終ジャッジ日時 2023-09-26 21:02:36
合計ジャッジ時間 3,062 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
6,188 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 7 ms
5,496 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 5 ms
4,640 KB
testcase_08 AC 7 ms
5,776 KB
testcase_09 AC 7 ms
5,752 KB
testcase_10 AC 5 ms
5,108 KB
testcase_11 AC 5 ms
4,840 KB
testcase_12 AC 5 ms
4,864 KB
testcase_13 AC 9 ms
6,568 KB
testcase_14 AC 9 ms
6,560 KB
testcase_15 AC 10 ms
6,544 KB
testcase_16 AC 9 ms
6,568 KB
testcase_17 AC 9 ms
6,660 KB
testcase_18 AC 6 ms
6,556 KB
testcase_19 AC 7 ms
6,636 KB
testcase_20 AC 7 ms
6,660 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const ll MOD=998244353;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    int n=s.size();
    vector<ll>P(n+1);
    P[0]=1;
    rep(i,n)P[i+1]=2*P[i]%MOD;
    vector<int>X(n+1),Y(n+1);
    rep(i,n){
        X[i+1]=X[i];
        Y[i+1]=Y[i];
        if(s[i]=='0')X[i+1]++;
        if(s[i]=='?')Y[i+1]++;
    }
    ll ans=0;
    rep(i,n){
        ll xl=X[i],xr=X[n]-X[i];
        ll yl=Y[i],yr=Y[n]-Y[i];
        if(s[i]=='?')yr--;
        if(s[i]!='0'){
            ll c=1;
            c*=(xl*P[yl]+yl*(yl==0?0:P[yl-1]))%MOD;
            c%=MOD;
            c*=(xr*P[yr]+yr*(yr==0?0:P[yr-1]))%MOD;
            c%=MOD;
            ans+=c;
            ans%=MOD;
        }
    }
    cout<<ans<<"\n";
}
0