Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD=998244353;

ll po[302][302];
ll C[602][602];
void init(){
	for(int i=0;i<302;i++){
		po[i][0]=1;
		for(int j=0;j+1<302;j++){
			po[i][j+1]=po[i][j]*i;
			po[i][j+1]%=MOD;
		}
	}
	for(int i=0;i<602;i++){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<=i-1;j++){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			C[i][j]%=MOD;
		}
	}
}

int main(){
	init();
	string s;
	ll k;
	cin>>s>>k;
	
	ll n=0;
	ll c[302];
	ll cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			c[n++]=cnt;
			cnt=0;
		}
		else cnt++;
	}
	c[n++]=cnt;
	
	/*cout<<n<<endl;
	for(int i=0;i<n;i++){
		cout<<c[i]<<" ";
	}cout<<endl;*/
	
	static ll dp[4][302][302]={};
	static ll t=0,t_=1;
	dp[t][0][0]=1;
	for(int x=0;x<n;x++){
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				dp[t_][i][j]=dp[2][i][j]=dp[3][i][j]=0;
			}
		}
		for(int i=0;i<302;i++){
			if(i+c[x]+1>=302)continue;
			for(int j=0;j<302;j++){
				if(dp[t][i][j]==0)continue;
				for(int y=1;y<=j;y++){
					dp[3][i+c[x]+1][y]+=MOD-dp[t][i][j]*C[j-y+c[x]][j-y]%MOD;
				}
			}
		}
		/*for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[3][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");*/
		for(int i=1;i<302;i++){
			for(int j=300;j>=1;j--){
				dp[2][i][j]=dp[t][i-1][j]+dp[2][i-1][j]+dp[2][i][j+1];
				dp[2][i][j]%=MOD;
			}
			for(int j=1;j<=300;j++){
				dp[2][i][j]+=dp[3][i][j];
				dp[2][i][j]%=MOD;
			}
		}
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				dp[t_][i][j]=dp[2][i][j];
				if(j>0){
					dp[t_][i][j]+=dp[t][i][j-1];
					if(dp[t_][i][j]>=MOD)dp[t_][i][j]-=MOD;
				}
			}
		}
		swap(t,t_);
		/*for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[t][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");*/
	}
	
	ll ret=0;
	for(int i=0;i<=min(k,301);i++){
		for(int j=1;j<=301;j++)ret+=dp[t][i][j];
	}
	cout<<ret%MOD<<endl;
	
	/*ll dp[2][302][302]={};
	ll t=0,t_=1;
	dp[t][0][0]=1;
	for(int x=0;x<n;x++){
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				dp[t_][i][j]=0;
			}
		}
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				if(dp[t][i][j]==0)continue;
				dp[t_][i][j]+=dp[t][i][j];
				dp[t_][i][j+1]+=MOD-dp[t][i][j]*(x+1-i)%MOD;
				dp[t_][i+1][j+1]+=dp[t][i][j]*(x-i)%MOD;
				dp[t_][i+1][j+c[x]+1]+=MOD-dp[t][i][j]*po[x-i][c[x]+1]%MOD;
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[t_][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");
		for(int i=0;i<302;i++){
			dp[t_][i][0]%=MOD;
			for(int j=0;j+1<302;j++){
				dp[t_][i][j+1]+=dp[t_][i][j]*(x+1-i);
				dp[t_][i][j+1]%=MOD;
			}
		}
		swap(t,t_);
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[t][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");
	}
	
	ll ret=0;
	for(int i=0;i<302;i++){
		for(int j=0;j<=k;j++){
			ret+=dp[t][i][j];
		}
	}
	cout<<ret%MOD<<endl;*/
}



Compiler output:
a.cc: In function 'int main()':
a.cc:102:27: error: no matching function for call to 'min(ll&, int)'
  102 |         for(int i=0;i<=min(k,301);i++){
      |                        ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:102:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  102 |         for(int i=0;i<=min(k,301);i++){
      |                        ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:102:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  102 |         for(int i=0;i<=min(k,301);i++){
      |                        ~~~^~~~~~~