Logo
(追記) (追記ここまで)

20612번 - String Distance 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB1522100.000%

문제

For two strings $S$ and $T,ドル you can do the following operation an 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]$ and $B[1..m],ドル and also $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 continuous substring $A[l_i..r_i]$ and the whole string $B$.

입력

The first line contains a single integer $T$ (1ドル \leq T \leq 10$), the number of test cases. For each test case:

The first line contains a string $A$ which consists of $n$ (1ドル \leq n \leq 100,000円$) lower-case English letters.

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

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

Each of the following $q$ lines contains two integers $l_i$ and $r_i$ (1ドル \leq l_i \leq r_i \leq n$) describing a query.

출력

For each query, print a single line containing an integer denoting the answer.

제한

예제 입력 1

1
qaqaqwqaqaq
qaqwqaq
3
1 7
2 8
3 9

예제 출력 1

4
2
0

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2020 > Day 3: Songyang Chen Contest 3 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /