#P2030. 遥控车
遥控车
Description
Pingping takes Yunyun to an amusement park and sees beautiful remote-controlled cars. Each car has a unique name name[i]. Yunyun has long wanted to play the car whose name is . However, since Yunyun is still young, the name she imagines might be a prefix of some car’s name (that is, there exists an such that is a prefix of name[i]); in this case, she can play the -th car. Or it might be a completely made-up name that is not a prefix of any car’s name; in that case, she cannot play anything.
You need to complete the following tasks:
-
Yunyun thinks of desired names. Tell her how many times she can play.
-
Due to the staff’s careless operation, each car’s placement may have a slight error: the original -th car may now be at any one of the positions , , or (the position of the -st car cannot be , and the position of the -th car cannot be ). Calculate how many possible permutations there are.
Note: The testdata guarantees that when is a prefix of name[i], the index is uniquely determined. A car can be played multiple times.
Input Format
The first line contains two positive integers and .
The next lines each contain one string name[i], the name of the -th car. Then the next lines each contain one string , the name Yunyun wants.
Output Format
Output two lines:
- The first line contains the number of times Yunyun can play.
- The second line contains the number of possible permutations.
4 4
Abcd
DeF
AAa
aBccc
Ab
AA
AbC
aBcc
3
5
Hint
Note:
- All strings are strictly case-sensitive and have length less than .
Constraints:
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号