the thirteenth day - hash_open addressing
重铸华农荣光 我辈义不容辞
the thirteenth day - hash_open addressing
0x3f3f3f3f and memset(h,0x3f,sizeof h) is the most significant among these.
#include<iostream>
#include<cstring>
using namespace std;
const int N=200003;
const int null=0x3f3f3f3f;
int h[N];
int find(int x)
{
int t=(x%N+N)%N;
while(h[t]!=null&&h[t]!=x)
{
t++;
if(t==N) t=0;
}
return t;
}
int main()
{
int n;
cin>>n;
memset(h,0x3f,sizeof h);
while(n--){
char op[5];
cin>>op;
int x;
cin>>x;
if(op[0]=='I'){
h[find(x)]=x;
}else{
if(h[find(x)]==null) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
return 0;
}