#include <stdio.h> #include <string.h> #define MU 26 #define WLEN (100 + 2) struct node{ int pr; node *child[MU]; node() { pr = 0; memset(child,NULL,sizeof(child)); } }; char findStr[WLEN],temp[WLEN]; char findMap[][5] = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; int findPr; void clear(node *root) { for(int i=0;i<MU;i++) { if(root->child[i] != NULL) clear(root->child[i]); } delete root; } void insert(node *root, char *str, int pr) { node *p = root; int len = strlen(str); for(int i=0; i<len; i++) { int k = str[i] - 'a'; if(p->child[k] == NULL) { p->child[k] = new node; } p->child[k]->pr += pr; p = p->child[k]; } } void dfs(node *root, char *str, int cur, int n) // end n-1 { if(cur == n) { if(root->pr > findPr) { findPr = root->pr; memcpy(findStr,temp,sizeof(findStr)); findStr[cur] = '