P10468 兔子与兔子
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=212370440130137957ll;
string s;
ll len,q,l1,l2,r1,r2,p[2000005];
ll h[2000005];
ll haash(ll l,ll r){
return (h[r]-((h[l-1]*p[r-l+1])%mod)+mod)%mod;
}
int main(){
cin>>s;
len=s.length();
p[0]=1;
for(int i=1;i<=len;i++){
p[i]=(p[i-1]*231)%mod;
}
for(int i=0;i<len;i++){
h[i+1]=(((h[i]*231)%mod)+s[i]-'a'+1+mod)%mod;
}
cin>>q;
while(q--){
cin>>l1>>r1>>l2>>r2;
if(haash(l1,r1)==haash(l2,r2)){
cout<<"Yes\n";
}
else
cout<<"No\n";
}
}
不知道为什么wa了