Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めで昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s;
    cin >> s;

    int si = s.size();
    int snu[si];
    int t[si*2];
    int snut[si];
    int tt[si*2];

    ll two[4100] ={};

    two[0] = 1;
    srep(i,1,4050){
        two[i]=two[i-1]*2;
        if(two[i]>998244353){
            two[i] %= 998244353;
        }
    }

    rep(i,si){
        if(s[i]=='0'){
            snu[i]=0;
            snut[i]=0;
        }
        if(s[i]=='1'){
            snu[i]=1;
            snut[i]=1;
        }
        if(s[i]=='2'){
            snu[i]=2;
            snut[i]=2;
        }
    }

    // 赤なら0,青なら1
    // 辞書順最初
    rep(i,si*2){
        if(i%2==0){
            if(snu[0]==2){
                t[i]=1;
            }else{
                t[i]=0;
            }
            rep(j,si-1-(i/2)){
                if(snu[j]==0&&snu[j+1]<2){
                    snu[j] = 0;
                }else if(snu[j]==0&&snu[j+1]==2){
                    snu[j]=1;
                }else if(snu[j]==1&&snu[j+1]==2){
                    snu[j]=2;
                }else if(snu[j]==2&&snu[j+1]!=2){
                    snu[j]=1;
                }
            }
            if(snu[si-1-(i/2)]==0){
                snu[si-1-(i/2)]=3;
            }else{
                snu[si-1-(i/2)]=4;
            }
        }else{
            if(snu[0]==2||snu[0]==4){
                t[i]=1;
            }else{
                t[i]=0;
            }
            rep(j,si-1-(i/2)-1){
                if(snu[j]==0&&snu[j+1]<2){
                    snu[j] = 0;
                }else if(snu[j]==0&&snu[j+1]==2){
                    snu[j]=1;
                }else if(snu[j]==1&&snu[j+1]==2){
                    snu[j]=2;
                }else if(snu[j]==2&&snu[j+1]!=2){
                    snu[j]=1;
                }
            }
            if(snu[si-1-(i/2)-1]==0&&snu[si-1-(i/2)]==4){
                snu[si-1-(i/2)-1] = 1;
            }else if(snu[si-1-(i/2)-1]==1&&snu[si-1-(i/2)]==4){
                snu[si-1-(i/2)-1] = 2;
            }else if(snu[si-1-(i/2)-1]==2&&snu[si-1-(i/2)]==3){
                snu[si-1-(i/2)-1] = 1;
            }
        }
        /*

        rep(j,i+1){
            cout << t[j];
        }
        cout << endl;
        */
    }
    int cm[si*2] = {};
    rep(i,si*2){
        //cout << t[i];
        if(i==0){
            cm[i]=t[i];
        }else{
            cm[i]=t[i]+cm[i-1];
        }
        
    }
    //cout << endl;

    // 辞書順最後
    rep(i,si*2){
        if(i%2==0){
            if(snut[0]==0){
                tt[i]=0;
            }else{
                tt[i]=1;
            }
            rep(j,si-1-(i/2)){
                if(snut[j]==0&&snut[j+1]!=0){
                    snut[j] = 1;
                }else if(snut[j]==0&&snut[j+1]==0){
                    snut[j]=0;
                }else if(snut[j]==1&&snut[j+1]==0){
                    snut[j]=0;
                }else if(snut[j]==2&&snut[j+1]==0){
                    snut[j]=1;
                }
            }
            if(snut[si-1-(i/2)]!=2){
                snut[si-1-(i/2)]=3;
            }else{
                snut[si-1-(i/2)]=4;
            }
        }else{
            if(snut[0]==0||snut[0]==3){
                tt[i]=0;
            }else{
                tt[i]=1;
            }
            rep(j,si-1-(i/2)-1){
                if(snut[j]==0&&snut[j+1]!=0){
                    snut[j] = 1;
                }else if(snut[j]==0&&snut[j+1]==0){
                    snut[j]=0;
                }else if(snut[j]==1&&snut[j+1]==0){
                    snut[j]=0;
                }else if(snut[j]==2&&snut[j+1]==0){
                    snut[j]=1;
                }
            }
            if(snut[si-1-(i/2)-1]==0&&snut[si-1-(i/2)]==4){
                snut[si-1-(i/2)-1] = 1;
            }else if(snut[si-1-(i/2)-1]==1&&snut[si-1-(i/2)]==3){
                snut[si-1-(i/2)-1] = 0;
            }else if(snut[si-1-(i/2)-1]==2&&snut[si-1-(i/2)]==3){
                snut[si-1-(i/2)-1] = 1;
            }
        }
        /*
        rep(j,i+1){
            cout << tt[j];
        }
        cout << endl;
        */
    }
    int cmm[si*2] = {};
    rep(i,si*2){
        //cout << t[i];
        if(i==0){
            cmm[i]=tt[i];
        }else{
            cmm[i]=tt[i]+cmm[i-1];
        }
        
    }

    ll dp[si*2][si*2+1];
    rep(i,si*2+1){
        dp[0][i]=0;
    }
    if(cm[0]==0)dp[0][0]=1;
    dp[0][1]=cmm[0];
    srep(i,si*2){
        rep(j,si*2+1){
            if(j<cm[i]){
                dp[i][j]=0;
            }else if(j>cmm[i]){
                dp[i][j]=0;
            }else{
                if(cm[i]<j&&j<cmm[i]){
                    dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
                    if(dp[i][j]>998244353){
                        dp[i][j] %= 998244353;
                    }
                }else if(cm[i]>j){

                }
            }
        }
    }
    

    return 0;
}
 
 


Compiler output:
a.cc:275:16: error: macro "srep" requires 3 arguments, but only 2 given
  275 |     srep(i,si*2){
      |                ^
a.cc:7:9: note: macro "srep" defined here
    7 | #define srep(i,s,t) for (int i = s; i < t; ++i)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:275:5: error: 'srep' was not declared in this scope
  275 |     srep(i,si*2){
      |     ^~~~