0
点赞
收藏
分享

微信扫一扫

L - Segment Occurrences

云上笔记 2022-02-09 阅读 35
c++

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∣&

举报

相关推荐

0 条评论