Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <string>#include <vector>using namespace std;int cnt = 0;struct TireNode {char ch;int cnt = 0;vector<TireNode*> child;};void insert(string str, TireNode* &head) {TireNode* p = head;for (char ch : str) {bool flag = false;auto it = p->child.begin();for (; it != p->child.end(); ++it) {if ((*it)->ch == ch) {(*it)->cnt++;p = (*it);flag = true;break;}}if (!flag) {TireNode* tmp = new TireNode;tmp->ch = ch;tmp->cnt++;