#include #include #include #include using namespace std; char buff[1024]; struct node { node* next[26]; //int flag;/// If this is the end of some word int step;/// Depth. }; node _root; node* root=&_root; int main() { int maxstep=0; int n; scanf("%d%*c",&n); for(int i=0;inext[buff[j]-'a']) { p=p->next[buff[j]-'a']; } else { node* q=new node; memset(q,0,sizeof(node)); q->step=p->step; p->next[buff[j]-'a']=q; p=q; } } p->step++; maxstep=max(maxstep,p->step); } printf("%d\n",maxstep); return 0; }