#include #include struct trie{ int n; trie *up; trie *down[26]; }root; int insert(char *s) { int i,j,k,ii; struct trie *p=&root,*q; j=strlen(s); for(i=0;idown[k]==0) { p->down[k]=q=new trie; for(ii=0;ii<26;ii++) q->down[ii]=0; q->up=p;q->n=0; } p=p->down[k]; p->n++; } return 0; } int delete2(char *s) { int i,j,k,kk; struct trie *p=&root; j=strlen(s); for(i=0;idown[k]==0) return -1;; p=p->down[k]; } kk=p->n; p=p->up; p->down[k]=0; if(kk==0) return -1; for(i=1;in-=kk; p=p->up; } return 0; } int search(char *s) { int i,j,k; struct trie *p=&root; j=strlen(s); for(i=0;idown[k]==0) return 0; p=p->down[k]; } return p->n; } int n; char mo[10],word[32]; int main() { int i,j,k; for(i=0;i<26;i++) root.down[i]=0; root.up=0;root.n=0; scanf("%d",&n); while(n-->0) { scanf("%s %s",mo,word); if(mo[0]=='i') insert(word); else if(mo[0]=='d') delete2(word); else { if(search(word)==0) printf("No\n"); else printf("Yes\n"); } } return 0; }