做法:利用set的count函数来查找元素
#include <bits/stdc++.h>
using namespace std;
int main()
{
set <string> s;//定义set
int n;
cin>>n;//输入
for(int i=1;i<=n;i++)
{
string a,b;
cin>>a>>b;//输入
if(a=="insert")
{
s.insert(b);//插入元素
}
if(a=="find")
{
if(s.count(b)==1)//查找有没有
{
cout<<"yes"<<endl;//输出
}
else
{
cout<<"no"<<endl;//输出
}
}
}
return 0;
}