1 #include<iostream>
  2 #include<climits>
  3 #include <cstdlib>
  4 #include <string.h>
  5 
  6 using namespace std;
  7 
  8 
  9 
 10 struct WORD
 11 {
 12     char *word;
 13     WORD *next;
 14 };
 15 
 16 
 17 static     WORD first;
 18 
 19 int main()
 20 {
 21     int N;
 22     string order;
 23     char *word;
 24     WORD *newword;
 25     
 26     first.word = "";
 27     first.next = NULL;
 28     cin >> N;
 29     cin.get();
 30 
 31 
 32     while(N--)
 33     {
 34         cin >> order;
 35         word = new char[31];
 36         cin >> word;
 37 
 38         if(order == "delete")    
 39         {
 40             int i;
 41             WORD *temp = first.next;
 42             WORD *pre = &first;
 43             
 44             while(temp != NULL)
 45             {
 46                 i = 0;
 47                 while(*(word + i) != '\0')
 48                 {
 49                     if(*(word + i) != *(temp->word + i))
 50                             break;
 51                     i++;
 52                 }
 53                 if(*(word + i) == '\0')
 54                 {
 55                     pre->next = pre->next->next;
 56                     temp = pre;
 57                 }
 58                 pre = temp;
 59                 temp = temp->next;
 60             }
 61         }
 62         else if(order == "insert")
 63         {
 64             newword = new WORD;
 65             newword->word = word;
 66             newword->next = NULL;
 67             WORD *temp = &first;
 68             while(temp->next != NULL)
 69             {
 70                 temp = temp->next;
 71             }
 72             temp->next = newword;
 73         }
 74         else if(order == "search")
 75         {
 76             int i;
 77             bool key = false;
 78             WORD *temp = first.next;
 79             
 80             while(temp != NULL && !key)
 81             {
 82                 i = 0;
 83                 while(*(word + i) != '\0')
 84                 {
 85                     if(*(word + i) != *(temp->word + i))
 86                     {
 87                         
 88                         break;
 89                     }
 90                     i++;
 91                 }
 92                 if(*(word + i) == '\0')
 93                 {
 94                     key = true;
 95                 }
 96                 temp = temp->next;
 97             }
 98             
 99             if(key)
100             {
101                 cout << "Yes" << endl;
102             }
103             else
104             {
105                 cout << "No" << endl;
106             }
107         }
108     }
109 }