This is what I picked garbage can stuck out a bunch of greedy.
We consider dp
consider how many pair of segments, and each segment is considered not 0,
then recursion formula is obtained
if the current string is 0
dp [I] [0] = dp [-I. 1] [0] + dp [I -1] [1], 0 // we put this out, all the programs are previously formed for a new program
dp [i] [1] = dp [i-1] [1]; // go directly fight
If it is not 0
DP [I] [0] = 0;
DP [I] [. 1] DP = [. 1-I] [. 1] + 2 * DP [-I. 1] [0]; // for dp [i- 1] [1] for fight or do not fight for dp [i-1] [0 ] is not only to fight.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
int n;string s;
bool ning[100005];int cnt=0;
ll dp[100005][2];
int main(){
ios::sync_with_stdio(false);
cin>>n>>s;s="*"+s;
int tmp=0,len=0;
for(int i=1;i<=n;i++){
tmp=(tmp+s[i]-'0')%3;
len++;
if(!tmp){
ning[++cnt]=(len==1&&s[i]=='0');
len=0;
}
}
if(tmp)cout<<0<<endl;
else{
dp[0][0]=1;dp[0][1]=0;
for(int i=1;i<=cnt;i++){
if(ning[i]){
dp[i][1]=dp[i-1][1];
dp[i][0]=(dp[i-1][0]+dp[i-1][1])%mod;
}else{
dp[i][0]=0;
dp[i][1]=(dp[i-1][1]*2+dp[i-1][0])%mod;
}
}
cout<<(dp[cnt][0]+dp[cnt][1])%mod;
}
}