#include<string.h>
#include<iostream>
using namespace std;
int n,m,q,a[1000+10];
int main()
{
string s,t;
cin>>n>>m>>q;
cin>>s>>t;
for(int i=0;i<n-m+1;i++)//预处理,如果i位置为t的起始位置,则a[I]=1;
if(s.substr(i,m)==t) a[i]=1;
while(q--)
{
int l,r;
int ans=0;
cin>>l>>r;
l--;
r--;
for(int i=l;i<=r-m+1;i++)
if(a[i]) ans++;
cout<<ans<<endl;
}
return 0;
}
1016B. Segment Occurrences
猜你喜欢
转载自blog.csdn.net/weixin_43870649/article/details/88724905
今日推荐
周排行