蒟蒻一个
样例过了
wa 0分求调
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
ULL N=31;
ULL a[1000010];
string s;
int m,l1,r1,l2,r2;
const int P=131;
ULL p[1000010],h[100010];
void init(){
s=' '+s;
p[0]=1,h[0]=0;
for(int i=1;i<s.size();i++){
p[i]=p[i-1]*P;
h[i]=h[i-1]*P+s[i];
}
}
ULL get(int l,int r){
return h[r]-h[l-1]*p[r-l+1];
}
bool substr(int l1,int r1,int l2,int r2){
return get(l1,r1)==get(l2,r2);
}
int main(){
cin>>s>>m;
init();
while(m--){
cin>>l1>>r1>>l2>>r2;
if(substr(l1,r1,l2,r2)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}