#P8697. [蓝桥杯 2019 国 C] 最长子序列

[蓝桥杯 2019 国 C] 最长子序列

Problem Description

We say that a string SS contains a string TT if TT is a subsequence of SS. That is, we can pick some characters from SS and keep their original order to form a new string that is exactly the same as TT. Given two strings SS and TT, starting from the first character of TT, what is the maximum number of consecutive characters that are contained in SS?

Input Format

Two lines, each containing one string. The first line is SS, and the second line is TT. Both strings are non-empty and contain only uppercase English letters.

Output Format

Output one integer, the answer.

ABCDEABCD
AABZ

3

Hint

For 20%20\% of the testdata, 1TS201 \le |T| \le |S| \le 20.

For 40%40\% of the testdata, 1TS1001 \le |T| \le |S| \le 100.

For all testdata, 1TS10001 \le |T| \le |S| \le 1000.

Problem F of Group C in the 2019 Lanqiao Cup National Contest.

Translated by ChatGPT 5