骷髅

· · 题解

不是这题和骷髅打金服有关系么??SZ吧

//Hash_Table
const int MASK = (1<<19)-1;
int Hd[MASK+1],Idx;
int Ne[maxn],C[maxn];
XI Wx[maxn];
inline void Insert(const XI &X){
    const int p=X&MASK;
    for(int i=Hd[p];i!=-1;i=Ne[i])
        if(Wx[i]==X)
            return C[i]++,void();
    C[++Idx]=1,Wx[Idx]=X,Ne[Idx]=Hd[p],Hd[p]=Idx;
}
inline void Reset(const XI &X){
    Hd[X&MASK]=-1;
}
inline int Query(const XI &X){
    const int p=X&MASK;
    for(int i=Hd[p];i!=-1;i=Ne[i])
        if(Wx[i]==X)
            return C[i];
    return 0;
}