Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.
You will be given a string s of length n.
Consider substring s[i, n] (where i is the starting position and n is the ending position) of s as a string called suffi.
You need to perform m queries on that string. A query is defined as:
The first line of the input is followed by two integers n (1 ≤ n ≤ 103) and m (1 ≤ m ≤ 106).
The second line contains the string s of only lowercase letters.
Each of the next m lines contains four integers L, R, P, Q (1 ≤ L ≤ R ≤ n, 1 ≤ P ≤ Q ≤ n).
Input | Output |
---|---|
5 1 agree 1 5 1 1 | 11 |
All the suffixes of "agree"
Now we are calculating
So, answer is 4 + 3 + 2 + 1 + 1 = 11 |
79% Solution Ratio
kzvd4729Earliest,
Uniquepro.Fastest, 0.2s
samiulsamiLightest, 12 MB
sakib_muhitShortest, 979B
Login to submit