code:
#include<bits/stdc++.h>//xfl using namespace std; const int N = 100007; typedef unsigned long long ull; ull mis[N],sum[N]; string s; int n,m,l1,l2,r1,r2; int main() { cin>>n>>m>>s; mi[0]=1; for(int i=1;i<=n;++i) { mi[i]=mi[i-1]*131; sun[i]=sum[i-1]*131+s[i-1]; } for(int i=1;i<=m;++i) { scanf("%d%d%d%d",&l1,&r1,&l2,&r2); int l=r1-l1+1; ull h1=sum[r1]-sum[l1-1]*mi[l]; ull h2=sum[r2]-sum[l2-1]*mi[l]; if(h1==h2)puts("Yes"); else puts("No"); } return 0; }