哈希表/散列表 指针版模版
#include<cstdio> #include<cstring> #include<cstdlib> #include<vector> #include<algorithm> using namespace std; const int N = 2010; const int M = 10010; typedef long long LL; const int SIZE = 100003; const int SEED = 13333; struct Node{ LL key; int type; Node *next; Node *set(LL _key,Node *_next ){ key = _key; next = _next; type = -1; return this; } }; Node Base[SIZE]; struct Hash{ Node *H[SIZE], *cur; int mark[N], cmark; void clear(){ cur = Base; cmark++; } Hash(){ memset(mark,0,sizeof(mark)); cmark = 0; } int &find(LL key){ int h = key%SEED; if( mark[h] < cmark ) mark[h] = cmark, H[h] = 0; for(Node *p = H[h]; p ; p = p->next ) if( p->key == key ) return p->type; H[h] = (cur++)->set(key,H[h]); return H[h]->type; } }H; int main(){ return 0; }