const int hashmod=4000007;
struct HAsh{
int head[hashmod],next[500005];
ll S[500005];
int tot;
int added[500005];
int adtot;
void add(ll s){
int tmp=abs(s)%hashmod;
if(head[tmp]==0)added[++adtot]=tmp;
++tot;
S[tot]=s;
next[tot]=head[tmp];head[tmp]=tot;
}
int que(ll s){
for (int i=head[abs(s)%hashmod];i;i=next[i])if(S[i]==s)return 1;
return 0;
}
void cl(){
for (int i=1;i<=adtot;i++)head[added[i]]=0;
adtot=0;
tot=0;
}
}H1;
手写哈希模板
最新推荐文章于 2024-09-18 09:45:21 发布