#x1053. CF710F String Set Queries
CF710F String Set Queries
String Set Queries
题面翻译
维护一个字符串集合,支持三种操作:
- 加字符串
- 删字符串
- 查询集合中的所有字符串在给出的模板串中出现的次数
操作数 ,输入字符串总长度 。
本题强制在线,应该在每次输出后调用fflush(stdout)
。你只有在输出上一个询问的答案后才能读入下一组询问。
题目描述
You should process queries over a set of strings. Each query is one of three kinds:
- Add a string to the set . It is guaranteed that the string was not added before.
- Delete a string from the set . It is guaranteed that the string is in the set .
- For the given string find the number of occurrences of the strings from the set . If some string from has several occurrences in you should count all of them.
Note that you should solve the problem in online mode. It means that you can't read the whole input at once. You can read each query only after writing the answer for the last query of the third type. Use functions fflush in C++ and BufferedWriter.flush in Java languages after each writing in your program.
输入格式
The first line contains integer ( ) — the number of queries.
Each of the next lines contains integer ( ) and nonempty string — the kind of the query and the string to process. All strings consist of only lowercase English letters.
The sum of lengths of all strings in the input will not exceed .
输出格式
For each query of the third kind print the only integer — the desired number of occurrences in the string .
样例 #1
样例输入 #1
5
1 abc
3 abcabc
2 abc
1 aba
3 abababc
样例输出 #1
2
2
样例 #2
样例输入 #2
10
1 abc
1 bcd
1 abcd
3 abcd
2 abcd
3 abcd
2 bcd
3 abcd
2 abc
3 abcd
样例输出 #2
3
2
1
0