你的任务是编写一个简单的字典程序,它实现以下指令:
insert str:在字典中插入一个字符串str。
find str:如果字典包含str,则打印'yes',否则打印'no'。
输入
在第一行 n 中,给出了指令的数量。
在接下来的 n 行中,n 条指令以上述格式给出。
输出
为一行中的每个查找指令打印"yes"或"no"。
约束
字符串由“A”、“C”、“G”或“T”组成
1 ≤ 字符串长度 ≤ 12
n ≤ 1000000
输入样例
13 insert AAA insert AAC insert AGA insert AGG insert TTT find AAA find CCC find CCC insert CCC find CCC insert T find TTT find T
输出样例
yes no no yes yes yes
#include<stdio.h>
#include<iostream>
using namespace std;
#include<string>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
const int maxn=100005;
typedef long long ll;
int main()
{
char zifu[20];
char zhiling[20];
ll t;
cin>>t;
set<string>s;
while(t--)
{
cin>>zhiling>>zifu;
if(zhiling[0]=='i')
{
s.insert(zifu);
}
else if(zhiling[0]=='f')
{
if(s.find(zifu)!=s.end())
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
}
return 0;
}