1:
map 可以做 ,但是输入实在恶心,有空串之类的HASH模板:
            
int Hash(char *s)
{
   int seed=131,sum=0;
   while (*s)
   sum=sum*seed+(*s++);
   return (sum&0x7FFFFFFF)%N;
}
void hash_insert(int s)
{
   int h=Hash(c[s]);
   int u=head[h];
   while (u)
   {
     if (!strcmp(c[s],c[u]))
     {
      return;
     }
     u=next[u];
   }
   next[s]=head[h];
   head[h]=s;
   ++ans;
}虽然简单,但是要灵活用好也比较费力。
原文:http://www.cnblogs.com/forgot93/p/4342803.html