Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define int long long
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
const int N=6005,mod=1000000007;
int n,m,tot,q[N],sum[N],l[N],r[N],f[N][N],c[N][N];
char ch[N];
signed main(){
	n=read(); m=read();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+ch[i]-'0';
	for(int i=1;i<=m;i++){
		l[i]=read(); r[i]=read();
		if(r[i]>r[q[tot]])q[++tot]=i;
	}
	for(int i=0;i<N;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for(int i=1;i<=tot;i++){
		l[i]=l[q[i]]; r[i]=r[q[i]];
	}
	m=tot; l[m+1]=n+1; f[0][0]=1;
	for(int i=1;i<=m;i++){
		int t=sum[r[i]]-sum[r[i-1]];
		if(r[i]<l[i+1]){
			int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+1);
			for(int j=0;j+t<=jb&&j<=meiju;j++)f[i][0]=(f[i][0]+(ll)c[jb][j+t]*f[i-1][j])%mod;
		}else{
			int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+1);
			for(int j=0;j<=r[i]-l[i+1]+1;j++){
				for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
					f[i][j]=(f[i][j]+(ll)c[jb][k+t-j]*f[i-1][k])%mod;
				}
			}
		}
		//for(int j=0;j<=max(0,r[i]-l[i+1]);j++)cout<<f[i][j]<<" "<<i<<" "<<j<<endl;
	}
	//cout<<f[1][0]<<" "<<f[1][1]<<endl;
	cout<<f[m][0]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:53: error: no matching function for call to 'max(int, long long int)'
   57 |                         int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:57:53: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   57 |                         int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:57:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                         int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~
a.cc:60:53: error: no matching function for call to 'max(int, long long int)'
   60 |                         int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:60:53: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   60 |                         int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:60:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |                         int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~
a.cc:62:46: error: no matching function for call to 'max(long long int, int)'
   62 |                                 for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
      |                                           ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:62:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   62 |                                 for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
      |                                           ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:62:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   62 |                                 for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
      |                                           ~~~^~~~~~~