Lang:G++
Edit12345678910111213141516171819202122232425262728293031//hashmap借鉴于zieiuk@hihocoder#include <stdio.h>#include <string.h>#include <vector>#include <list>using namespace std;vector<int> unionset;vector<bool> visited;vector<char*> namevec;vector<int> result;vector<list<int> > rlist;vector<pair<int, int> > req;typedef list<int>::iterator iter;const int N = 100003;const int L = 101;struct hashnode {char str[L];int key;struct hashnode *next;} nodes[N << 1], *hashtable[N];int hashid;int hashfind(int hashkey, char *s){struct hashnode *node;for (node = hashtable[hashkey]; node && strcmp(node->str, s); node = node->next);return node == NULL ? -1 : (node - nodes);}int hashinsert(int hashkey, char *s, int key){strcpy(nodes[hashid].str, s);