!!RE悬关求助!!(^///^)
查看原帖
!!RE悬关求助!!(^///^)
1108111
XYY62012楼主2025/1/22 11:09
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2000006;
string s;
int m;
int l1,l2;
int r1,r2;
int p=13331;
ll hashe[N],d[N];
ll hashh(int a,int b){
    return hashe[b]-hashe[a-1]*d[b-a+1];
}
ll dff(){
    for(int i=1;i<s.size();i++){
        hashe[i]=hashe[i-1]*p+s[i];
        d[i]=d[i-1]*p; 
    }
}
int main(){
    cin>>s>>m;
    s=" "+s;
    d[0]=1;
    dff();
    for(int i=1;i<=m;i++){
        cin>>l1>>r1;
		cin>>l2>>r2;
        if(hashh(l1,r1)==hashh(l2,r2)){
            cout<<"Yes"<<endl;
        }  else{
            cout<<"No"<<endl;
        } 
    }
    return 0;
}
2025/1/22 11:09
加载中...