题目链接:点击这里
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 10000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int maxn = 1000010, base = 131;
char str[maxn];
ull h[maxn], p[maxn];
//O(1)查询[L,R]子串的哈希值
ull get(int l, int r)
{
return h[r] - h[l-1] * p[r-l+1];
}
int main()
{
scanf("%s", str + 1);
int n = strlen(str + 1);
p[0] = 1;
for(int i = 1; i <= n; ++i)
{
h[i] = h[i-1] * base + str[i] - 'a' + 1;
p[i] = p[i-1] * base;
}
int m;
scanf("%d", &m);
while(m--)
{
int l1, r1, l2, r2;
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;
}