結果
問題 | No.2219 Re:010 |
ユーザー | HIcoder |
提出日時 | 2023-07-08 17:12:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,235 bytes |
コンパイル時間 | 995 ms |
コンパイル使用メモリ | 104,004 KB |
実行使用メモリ | 17,444 KB |
最終ジャッジ日時 | 2023-09-29 18:37:32 |
合計ジャッジ時間 | 3,812 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 25 ms
15,232 KB |
testcase_04 | AC | 4 ms
4,684 KB |
testcase_05 | AC | 20 ms
12,692 KB |
testcase_06 | AC | 7 ms
5,756 KB |
testcase_07 | AC | 14 ms
8,952 KB |
testcase_08 | AC | 23 ms
14,716 KB |
testcase_09 | AC | 23 ms
14,176 KB |
testcase_10 | AC | 19 ms
11,556 KB |
testcase_11 | AC | 16 ms
10,220 KB |
testcase_12 | AC | 17 ms
10,260 KB |
testcase_13 | AC | 28 ms
17,388 KB |
testcase_14 | AC | 28 ms
17,340 KB |
testcase_15 | AC | 29 ms
17,392 KB |
testcase_16 | AC | 28 ms
17,372 KB |
testcase_17 | AC | 29 ms
17,328 KB |
testcase_18 | AC | 27 ms
17,444 KB |
testcase_19 | AC | 26 ms
17,324 KB |
testcase_20 | AC | 26 ms
17,324 KB |
testcase_21 | AC | 1 ms
4,380 KB |
testcase_22 | AC | 1 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,380 KB |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<ll,ll> P; typedef pair<int,P> PP; const ll MOD=998244353; const double PI=acos(-1); ll mod_pow(ll x,ll y,ll mod){ ll res=1; while(y>0){ if(y&1){ res*=x; res%=mod; } x*=x; x%=mod; y/=2; } return res; } int main(){ string S; cin>>S; int n=S.size(); vector<vector<ll>> dp(n+1,vector<ll>(4,0)); dp[0][0]=1; for(int i=0;i<n;i++){ if(S[i]=='0'){ dp[i+1][1]+=dp[i][0]; dp[i+1][3]+=dp[i][2]; } else if(S[i]=='1'){ dp[i+1][2]+=dp[i][1]; }else{ dp[i+1][1]+=dp[i][0]; dp[i+1][3]+=dp[i][2]; dp[i+1][2]+=dp[i][1]; } for(int j=0;j<4;j++){ dp[i+1][j]%=MOD; } for(int j=0;j<4;j++){ dp[i+1][j]+=dp[i][j]*(S[i]=='?'?2:1)%MOD; dp[i+1][j]%=MOD; } } ll ans=dp[n][3]; cout<<ans<<endl; }