From 6c3ff32521d42a5e9307c46b08a15b5ea6d2c4d9 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Thu, 22 Sep 2016 13:19:52 +0800 Subject: [PATCH] Create 1050.cpp --- QUSTOJ/1050.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 QUSTOJ/1050.cpp diff --git a/QUSTOJ/1050.cpp b/QUSTOJ/1050.cpp new file mode 100644 index 0000000..b04f158 --- /dev/null +++ b/QUSTOJ/1050.cpp @@ -0,0 +1,47 @@ +#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; +}