#P8112. [Cnoi2021] 符文破译
[Cnoi2021] 符文破译
Description
To protect the forbidden magic recorded in the spellbook, the author concatenated the magic affixes of spells together without spaces, forming a rune string denoted as .
All magic affixes that make up the rune string are recorded in an even older magic dictionary written by prophets, denoted as . Specifically, all non-empty prefixes of are valid magic affixes.
Being concise is the top priority when writing a spellbook, so the number of magic affixes used should be as small as possible. Therefore, when deciphering the spellbook, the fewer magic affixes is split into, the higher the chance that the deciphering is correct.
Cirno wants to know the minimum number of segments when splitting this spellbook into magic affixes.
In particular, if there is no valid splitting scheme, it means this spellbook is fake. Cirno will get a string Fake.
Input Format
The first line contains two integers, representing and .
The second line contains a string .
The third line contains a string .
Output Format
Output one line containing an integer or a string Fake, representing the answer.
3 5
aba
abaab
2
3 5
aba
ababa
2
3 5
aba
abbaa
Fake
Hint
Constraints and Notes
For of the testdata, it is guaranteed that , and $\texttt{S}_x, \texttt{T}_x \in [\texttt{a},\texttt{z}]$.
Subtasks
Subtask 1 ( points): .
Subtask 2 ( points): .
Subtask 3 ( points): .
Subtask 4 ( points): No special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号