#include #include #include struct node { int x,y; int step; int total; int mem[333]; int flag; }E[5011]; int x_s,y_s; int x_e,y_e; int queue[6066]; int K,Key; struct dictree { struct dictree *child[26]; int flag; }; struct dictree *root; int key; void insert(char *S) { struct dictree *cur,*New; int i,j; cur=root; for(i=0;S[i];i++) { if(cur->child[S[i]-'a']) cur=cur->child[S[i]-'a']; else { New=(struct dictree *)malloc(sizeof(struct dictree)); for(j=0;j<26;j++) New->child[j]=0; New->flag=-1; cur->child[S[i]-'a']=New; cur=New; } } cur->flag=key; } int find(char *S) { struct dictree *cur; int i; cur=root; for(i=0;S[i];i++) { if(cur->child[S[i]-'a']) cur=cur->child[S[i]-'a']; else return -1; } return cur->flag; } int BFS() { int i; K=0; while(Kchild[j]=0; root->flag=-1; Key=0; scanf("%d",&n); for(key=0;key