`//拉链法,用vector代替邻接表
include[HTML_REMOVED]
include[HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
const int N = 1e5 + 3;
vector[HTML_REMOVED] h[N];
void insert(int x)
{
int k = (x % N + N) % N;//将正负的哈希值都集中在0到N-1中
if(find(h[k].begin(), h[k].end(), x) == h[k].end())
h[k].push_back(x);
}
bool find(int x)
{
int k = (x % N + N) % N;//将正负的哈希值都集中在0到N-1中
if(find(h[k].begin(), h[k].end(), x) != h[k].end())
return true;//在链表当中
return false;//不在链表
}
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i ++ )
{
char op;
cin >> op;
int x;
cin >> x;
if(op == ‘I’)//插入
{
insert(x);
}
else//查询
{
if(find(x) == 0) cout << “No” << endl;
else cout << “Yes” << endl;
}
}
}`