Please implement a data structure to efficiently support four operations:
I
:
Inserts the string
into
.
No changes are made if
is already in
.
E
:
Erases the string
from
.
No changes are made if
is not in
.
C
:
Counts the number of strings in
that end with the suffix
.
R: Resets
,
that is, removes all strings from
.
Input consists of several operations over an initially empty . Assume that each is made up of between 1 and 100 lowercase letters. At no moment the sum of the sizes of the strings stored in will be larger than .
Print the result of each C
operation, and three dashes for each R operation.
Input
E a I abba C a I cba C cba C abba C a C ba I abba C ba E cba C cba C a E ba C ba R C ba I eggs I zzeggs C eggs E eggs C eggs
Output
1 1 1 2 2 2 0 1 1 --- 0 2 1