代码:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include<algorithm>
#include<cmath>
#include<map>
#include<string.h>
#include<string>
#include<cstring>
using namespace std;
const long long N = 200003;
const int P = 131;
typedef unsigned long long ULL;
ULL h[N], p[N];
char st[N];
int n, m;
ULL get(int l, int r)
{
return h[r] - h[l - 1] * p[r - l + 1];
}
int main()
{
scanf("%d%d%s", &n, &m, st + 1);
int l1, r1, l2, r2;
p[0] = 1;
for (int i = 1; i <= n; i++)
{
p[i] = p[i - 1] * P;
h[i] = h[i - 1] * P + st[i];
}
for (int i = 1; i <= m; i++)
{
scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
if (get(l1, r1) == get(l2, r2))
printf("Yes\n");
else
printf("No\n");
}
return 0;
}