Trie树可以高效地存储和查找字符串
int son[N][26],cnt[N],idx;void insert(string &A){ int p = 0; for(int i = 0;i < A.size();i ++ ) { int k = A[i] - 'a'; if(!son[p][k]) son[p][k] = ++idx; p = son[p][k]; } cnt[p]++;}int query(string &A){ int p = 0; for(int i = 0;i < A.size();i ++ ) { int k = A[i] - 'a'; if(!son[p][k]) return 0; p = son[p][k]; } return cnt[p];}