#P5840. [COCI 2014/2015 #5] Divljak
[COCI 2014/2015 #5] Divljak
Problem Description
Alice has strings , and Bob has a set of strings , which is empty at the beginning.
Then there will be operations. There are two types of operations:
1 P: Bob adds a string to his set.2 x: Alice asks Bob how many strings in set contain the string (we say string contains string if and only if is a substring of ).
Input Format
The first line contains an integer .
The next lines each contain a string .
The next line contains an integer .
The next lines each contain one operation.
Output Format
For each 2 x operation, output one integer per line, representing the answer.
3
a
bc
abc
5
1 abca
2 1
1 bca
2 2
2 3
1
2
1
Hint
For of the testdata, .
For of the testdata, . All strings consist of lowercase letters. The sum of lengths of all strings in and the sum of lengths of all strings are each .
Translated from COCI 2014/2015 CONTEST #5。
Translated by ChatGPT 5