Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <vector>#include <string>#include <map>using namespace std;//字典树节点定义class Node {public:int id;Node* children[26];Node(int d) : id(d) {for (int i = 0; i < 26; ++i) {children[i] = NULL;}}};Node * findChild(Node *root, char c) {int idx;if (c >= 'A' && c <= 'Z') idx = c - 'A';else idx = c - 'a';return root->children[idx];}int findString(Node *root, string str) {Node *curNode = root;for (int j = 0; j < str.length(); ++j) {Node *p = findChild(curNode, str[j]);if (p == NULL) {return -1;