AcWing 840. 模拟散列表
原题链接
简单
作者:
Mystery_1
,
2024-03-04 19:44:09
,
所有人可见
,
阅读 23
//ACWing840.模拟散列表
#include<iostream>
#include<cstring>
using namespace std;
const int N=200003,null=0x3f3f3f3f;
int h[N];
int find(int x){
int k=(x%N+N)%N;
while(h[k]!=null&&h[k]!=x){
k++;
if(k==N)k=0;
}
return k;
}
int main(){
int n;
scanf("%d",&n);
memset(h,null,sizeof(h));
while(n--){
string op;
int x;
cin>>op>>x;
if(op=="I"){
int k=find(x);
h[k]=x;
}else{
if(find(x)!=null&&h[find(x)]==x)puts("Yes");
else puts("No");
}
}
return 0;
}