1 #include<stdio.h>
2 //#include<bits/stdc++.h>
3 #include<string.h>
4 #include<iostream>
5 #include<math.h>
6 #include<sstream>
7 #include<set>
8 #include<queue>
9 #include<map>
10 #include<vector>
11 #include<algorithm>
12 #include<limits.h>
13 #define inf 0x7fffffff
14 #define INFL 0x7fffffffffffffff
15 #define lson l,m,rt<<1
16 #define rson m+1,r,rt<<1|1
17 #define LL long long
18 #define ULL unsigned long long
19 using namespace std;
20
21 typedef struct Trie{
22 int v;
23 Trie *next[26];
24 }Trie;
25 Trie root;
26 void createTrie(char *str)
27 {
28 int len = strlen(str);
29 Trie *p = &root, *q;
30 for(int i=0; i<len; ++i)
31 {
32 int id = str[i]-‘a‘;
33 if(p->next[id] == NULL)
34 {
35 q = (Trie *)malloc(sizeof(root));
36 q->v = 1;
37 for(int j=0; j<26; ++j)
38 q->next[j] = NULL;
39 p->next[id] = q;
40 p = p->next[id];
41 }
42 else
43 {
44 p->next[id]->v++;
45 p = p->next[id];
46 }
47 }
48 }
49
50 int findTrie(char *str)
51 {
52 int len = strlen(str);
53 Trie *p = &root;
54 for(int i=0; i<len; ++i)
55 {
56 int id = str[i]-‘a‘;
57 p = p->next[id];
58 if(p == NULL)
59 return 0;
60 }
61 return p->v;
62 }
63 void dele(char *str,int n)
64 {
65 Trie *p = &root;
66 int len = strlen(str);
67 for(int i=0; i<len; ++i)
68 {
69 int id = str[i]-‘a‘;
70 p = p->next[id];
71 p->v-=n;
72 }
73 for(int j=0; j<26; ++j)
74 {
75 p->next[j] = NULL;
76 }
77 }
78 int main()
79 {
80 int t;
81 char s1[10000],s2[10000];
82 for(int i=0;i<26;i++)
83 {
84 root.next[i]=NULL;
85 }
86 cin>>t;
87 while(t--)
88 {
89 scanf("%s%s",s1,s2);
90 if(s1[0]==‘i‘)
91 {
92 createTrie(s2);
93 }
94 else if(s1[0]==‘s‘)
95 {
96 int ans=findTrie(s2);
97 if(ans)
98 {
99 puts("Yes");
100 }
101 else
102 {
103 puts("No");
104 }
105 }
106 else
107 {
108 int cnt=findTrie(s2);
109 if(cnt)
110 {
111 dele(s2,cnt);
112 }
113 }
114 }
115 return 0;
116 }