哈希.字符串哈希.AcWing.841
标签:ring 字符 can unsigned scan ace bsp 图片 div
code:
#include//xfl
using namespace std;
const int N = 100007;
typedef unsigned long long ull;
ull mis[N],sum[N];
string s;
int n,m,l1,l2,r1,r2;
int main()
{
cin>>n>>m>>s;
mi[0]=1;
for(int i=1;ii)
{
mi[i]=mi[i-1]*131;
sun[i]=sum[i-1]*131+s[i-1];
}
for(int i=1;ii)
{
scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
int l=r1-l1+1;
ull h1=sum[r1]-sum[l1-1]*mi[l];
ull h2=sum[r2]-sum[l2-1]*mi[l];
if(h1==h2)puts("Yes");
else puts("No");
}
return 0;
}
哈希.字符串哈希.AcWing.841
标签:ring 字符 can unsigned scan ace bsp 图片 div
原文地址:https://www.cnblogs.com/xfldbk/p/14197829.html
评论