結果
問題 | No.2219 Re:010 |
ユーザー | umezo |
提出日時 | 2023-02-17 22:40:18 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 835 bytes |
コンパイル時間 | 2,094 ms |
コンパイル使用メモリ | 203,116 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-07-19 13:51:28 |
合計ジャッジ時間 | 2,701 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; const int MOD=998244353; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); vector<ll> P(200200); P[0]=1; for(int i=1;i<200200;i++) P[i]=P[i-1]*2%MOD; string s; cin>>s; int n=s.size(); vector<ll> L(n),R(n); int l=0,l0=0; rep(i,n){ L[i]=l0*P[l]%MOD; if(l) L[i]=(L[i]+l*P[l-1]%MOD)%MOD; if(s[i]=='0') l0++; else if(s[i]=='?') l++; } int r=0,r0=0; for(int i=n-1;i>=0;i--){ R[i]=r0*P[r]%MOD; if(r) R[i]=(R[i]+r*P[r-1]%MOD)%MOD; if(s[i]=='0') r0++; else if(s[i]=='?') r++; } ll ans=0; for(int i=1;i<n-1;i++){ if(s[i]=='0') continue; ans=(ans+L[i]*R[i]%MOD)%MOD; } cout<<ans<<endl; return 0; }