#P4595. [COCI 2011/2012 #5] POPLOČAVANJE
[COCI 2011/2012 #5] POPLOČAVANJE
Description
There is a street consisting of lowercase English letters. The city government occasionally replaces the tiles on the street. However, letter tiles are in high demand, so the government only has kinds of letter tiles to choose from.
The pattern of the -th tile consists of letters. Tiles cannot be rotated or broken, and they can only be placed where the tile’s letters exactly match a contiguous substring of letters on the street.
Tiles may overlap, and multiple tiles with the same pattern may be used. If a street cannot be covered by any tiles, then it is bad.
Find how many bad streets there are.
Input Format
The first line contains an integer , the number of letters on the street.
The second line contains lowercase letters, the sequence on the street.
The third line contains an integer , the number of tiles.
The next lines each contain lowercase letters, describing the pattern of that tile.
Output Format
Print one line with an integer, the number of bad streets.
6
abcbab
2
cb
cbab
2
4
abab
2
bac
baba
4
6
abcabc
2
abca
cab
1
Hint
Constraints: , , .
Translated from COCI 2011/2012 #5 T6.
Translated by ChatGPT 5
京公网安备 11011102002149号