• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-65  評論-6  文章-0  trackbacks-0
             1 #include <cstdio>
             2 #include <cstring>
             3 #define MAXSIZE 50001
             4 char str[MAXSIZE][100];
             5 struct Tries{
             6     int nodes;
             7     Tries *next[26];
             8     Tries(){
             9         nodes=0;
            10         memset(next,NULL,sizeof(next));
            11     }
            12 };
            13 Tries *tree=new Tries();
            14 void insert(char word[]){
            15     Tries *temp=tree;
            16     int i=0;
            17     while(word[i]){
            18         int k=word[i]-'a';
            19         if(temp->next[k]==NULL)
            20             temp->next[k]=new Tries();
            21         temp=temp->next[k];
            22         i++;
            23     }
            24     temp->nodes++;
            25 }
            26 
            27 bool visited(char word[]){
            28     Tries *temp=tree;
            29     int i=0;
            30     while(word[i]){
            31         int k=word[i]-'a';
            32         if(temp->next[k]==NULL)
            33             return false;
            34         temp=temp->next[k];
            35         if(temp->nodes&&word[i+1]=='\0')
            36             return true;
            37         i++;
            38     }
            39     return false;
            40 }
            41 
            42 bool query(char word[]){
            43     Tries *temp=tree;
            44     int i=0;
            45     while(word[i]){
            46         int k=word[i]-'a';
            47         if(temp->next[k]==NULL)
            48             return false;
            49         temp=temp->next[k];
            50         if(temp->nodes&&visited(&word[i+1]))
            51             return true;
            52         i++;
            53     }
            54     return false;
            55 }
            56 int main(){
            57     #ifndef ONLINE_JUDGE
            58     freopen("in.txt","r",stdin);
            59     #endif 
            60     int j,i=0;
            61     while(gets(str[i]))
            62         insert(str[i++]);
            63     for(j=0;j<i;j++)
            64         if(query(str[j]))
            65             puts(str[j]);
            66     return 0;
            67 }
            posted on 2012-05-15 23:03 Leo.W 閱讀(154) 評論(0)  編輯 收藏 引用
            亚洲成色www久久网站夜月| 久久久久久曰本AV免费免费| 蜜桃麻豆www久久| 欧美激情精品久久久久久久九九九| 亚洲国产精品无码久久青草 | 免费精品99久久国产综合精品| 精品国产婷婷久久久| 久久笫一福利免费导航| 久久精品男人影院| 精品无码久久久久国产动漫3d| 韩国三级大全久久网站| 久久99精品国产麻豆宅宅| 久久99国产精品成人欧美| 久久精品国产久精国产果冻传媒| 51久久夜色精品国产| 久久久精品人妻一区二区三区蜜桃 | 国产产无码乱码精品久久鸭| 久久男人中文字幕资源站| 99国产精品久久| 国产aⅴ激情无码久久| 日韩亚洲国产综合久久久| 久久亚洲综合色一区二区三区 | 久久99久久99精品免视看动漫| 久久国产精品一区| 国产精品久久久久久久| 久久久久久精品免费免费自慰| 久久国产香蕉视频| 91久久精品视频| 精品久久久久久久久午夜福利| 久久精品国产男包| 欧美精品丝袜久久久中文字幕 | 久久天堂电影网| 色婷婷久久综合中文久久蜜桃av| 狠狠色丁香久久婷婷综合蜜芽五月| 久久99国产精品成人欧美| 久久91这里精品国产2020| 色综合久久中文色婷婷| 99国内精品久久久久久久| 88久久精品无码一区二区毛片 | 久久无码中文字幕东京热| 久久久久久久精品妇女99|