L - Segment Occurrences

给定两个字符串ss和tt,求在ss的子串中tt出现的次数。每行包含查询的开始和结束索引,输出每个查询的tt出现次数。
摘要由CSDN通过智能技术生成

L - Segment Occurrences

You are given two strings ss and tt, both consisting only of lowercase Latin letters.

The substring s[l..r]s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, \dots, s_rsl​,sl+1​,…,sr​ without changing the order.

Each of the occurrences of string aa in a string bb is a position ii (1 \le i \le |b| - |a| + 11≤i≤∣b∣−∣a∣+1) such that b[i..i + |a| - 1] = ab[i..i+∣a∣−1]=a (|a|∣a∣ is the length of string aa).

You are asked qq queries: for the ii-th query you are required to calculate the number of occurrences of string tt in a substring s[l_i..r_i]s[li​..ri​].

Input

The first line contains three integer numbers nn, mm and qq (1 \le n, m \le 10^31≤n,m≤103, 1 \le q \le 10^51≤q≤105) — the length of string ss, the length of string tt and the number of queries, respectively.

The second line is a string ss (|s| = n∣s∣&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值