CF710F.String Set Queries

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You should process mm queries over a set DD of strings. Each query is one of three kinds:

  1. Add a string ss to the set DD . It is guaranteed that the string ss was not added before.
  2. Delete a string ss from the set DD . It is guaranteed that the string ss is in the set DD .
  3. For the given string ss find the number of occurrences of the strings from the set DD . If some string pp from DD has several occurrences in ss 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 mm ( 1<=m<=31051<=m<=3·10^{5} ) — the number of queries.

Each of the next mm lines contains integer tt ( 1<=t<=31<=t<=3 ) and nonempty string ss — 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 31053·10^{5} .

输出格式

For each query of the third kind print the only integer cc — the desired number of occurrences in the string ss .

输入输出样例

  • 输入#1

    5
    1 abc
    3 abcabc
    2 abc
    1 aba
    3 abababc
    

    输出#1

    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
    
首页