#P4022. [CTSC2012] 熟悉的文章
[CTSC2012] 熟悉的文章
Description
Amiba is Xiao Qiang’s good friend.
In Xiao Qiang’s eyes, Amiba is a literary youth with excellent essay scores. To grasp the essence of exam essays, Xiao Qiang asked Amiba for guidance. Amiba showed him several essays. Xiao Qiang felt they looked very familiar, as if they were pieced together from some model essays. He cast a doubtful look at Amiba, only to see a sly smile.
To convincingly show how “familiar” Amiba’s essays feel, Xiao Qiang devised a quantitative metric for the “degree of familiarity” of an essay: . He first converts an essay into a string. Then he collects essays from various famous authors, also converts them into strings, and compiles a “standard essay library” containing strings.
Xiao Qiang considers the following: if a string has length at least and appears in some string in the standard essay library (i.e., it is a contiguous substring of some string in the library), then it is “familiar.” For an essay (a string) , if we can split into several substrings such that the total length of the “familiar” substrings is at least of the total length of , then is a “familiar article.” is the maximum among all that make a “familiar article” (if no such exists, define ).
For example:
Xiao Qiang’s essay library contains the following strings:
10110
000001110
There is an essay to be examined:
1011001100
Xiao Qiang computes that the maximum for this essay is , because the essay can be viewed as , where and are judged “familiar.” When or larger, no valid split exists. Therefore, this essay’s . Xiao Qiang believes that Amiba’s values are noticeably larger than other students’. Please help him verify this.
Input Format
The first line contains two integers , denoting the number of essays to check and the number of strings in Xiao Qiang’s standard essay library.
The next lines contain strings, forming the standard essay library.
The next lines contain strings, representing the essays.
Output Format
Output lines. Each line contains one integer, the value of the corresponding essay.
1 2
10110
000001110
1011001100
4
Hint
For of the testdata, the input file length does not exceed bytes.
For of the testdata, the input file length does not exceed bytes.
For of the testdata, the input file length does not exceed bytes.
For of the testdata, the input file length does not exceed bytes.
Translated by ChatGPT 5
京公网安备 11011102002149号