String Distance

TimeLimit:4000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
For two strings $S$ and $T$, you can do the following operation for arbitrary number of times: Select a string $S$ or $T$, insert or delete a character at any position. The distance between two strings $S$ and $T$ is defined as the minimum number of operations to make $S$ and $T$ equal.

You will be given two strings $A[1..n],B[1..m]$ and $q$ queries.

In each query, you will be given two integers $l_i$ and $r_i$ ($1\leq l_i\leq r_i\leq n$), you need to find the distance between the continous substring $A[l_i..r_i]$ and the whole string $B$.
Input
The first line of the input contains a single integer $T$ ($1 \leq T \leq 10$), the number of test cases.

For each case, the first line of the input contains a string $A$ consists of $n$ ($1\leq n\leq 100\,000$) lower-case English letters.

The second line of the input contains a string $B$ consists of $m$ ($1\leq m\leq 20$) lower-case English letters.

The third line of the input contains a single integer $q$ ($1\leq q\leq 100\,000$), denoting the number of queries.

Then in the following $q$ lines, there are two integers $l_i,r_i$ ($1\leq l_i\leq r_i\leq n$) in each line, denoting a query.
Output
For each query, print a single line containing an integer, denoting the answer.
SampleInput
1
qaqaqwqaqaq
qaqwqaq
3
1 7
2 8
3 9
SampleOutput
4
2
0
Submit
题目统计信息详细
总AC数3
通过人数2
尝试人数2
总提交量3
AC率66.67%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: