Hash表
完全顶替map
const int S=10000019;
struct HashMap{
std::vector<int>head,nxt;
struct node{
int x,v;
};std::vector<node>to;
inline void clear(){
head.resize(S+3,-1);
}
HashMap(){
clear();
}
inline int & operator[](int x){
int u=x%S;
for(int i=head[u];~i;i=nxt[i]){
if(to[i].x==x){
return to[i].v;
}
}
nxt.push_back(head[u]);
head[u]=to.size();
to.push_back({x,0});
return to[to.size()-1].v;
}
};

浙公网安备 33010602011771号