• <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 <stdio.h>
             2 #include <string.h>
             3 #include <math.h>
             4 #include <malloc.h>
             5 struct Tries{
             6     bool exist;
             7     bool end;
             8     Tries *num[10];
             9     Tries(){
            10         for(int i=0;i<10;i++)
            11             num[i]=NULL;
            12         exist=end=false;
            13     }
            14 };
            15 
            16 void insert(char *a,Tries *root){
            17     Tries *temp=root;
            18     int len=strlen(a);
            19     int i;
            20     for(i=0;i<len;i++){
            21         int k=a[i]-'0';
            22         if(temp->num[k]==NULL)
            23             temp->num[k]=new Tries;
            24         temp->exist=true;
            25         temp=temp->num[k];
            26     }
            27     temp->end=true;
            28 }
            29 
            30 bool find(char *a,Tries *root){
            31     Tries *temp=root;
            32     int len=strlen(a);
            33     int i;
            34     for(i=0;i<len;i++){
            35         int k=a[i]-'0';
            36         if(temp->end)
            37             return true;
            38         temp=temp->num[k];
            39     }
            40     if(temp->exist)
            41         return true;
            42     return false;
            43 }
            44 
            45 void del(Tries *root){
            46     int i;
            47     for(i=0;i<10;i++)
            48         if(root->num[i]!=NULL)
            49             del(root->num[i]);
            50     free(root);
            51 }
            52 int main(){
            53     //freopen("in.txt","r",stdin);
            54     int n;
            55     scanf("%d",&n);
            56     while (n--){
            57         Tries *tree;
            58         tree=new Tries;
            59         bool getIt=false;
            60         char str[11];
            61         int t;
            62         scanf("%d",&t);
            63         getchar();
            64         while (t--){
            65             gets(str);
            66             if(!getIt){
            67                 insert(str,tree);
            68                 getIt=find(str,tree);
            69             }
            70         }
            71         if(getIt)
            72             puts("NO");
            73         else
            74             puts("YES");
            75         del(tree);
            76 
            77     }
            78     return 0;
            79 }
            80 
            posted on 2012-05-15 08:57 Leo.W 閱讀(127) 評論(0)  編輯 收藏 引用
            国产精品VIDEOSSEX久久发布 | 久久激情亚洲精品无码?V| 久久久久久九九99精品| 青青青青久久精品国产h| 久久精品亚洲男人的天堂| 久久精品日日躁夜夜躁欧美| 麻豆成人久久精品二区三区免费| 99久久国产热无码精品免费久久久久| 亚洲国产成人久久综合一区77| 浪潮AV色综合久久天堂| 久久久艹| 99久久婷婷国产综合精品草原| 日韩欧美亚洲综合久久| 国产99久久久国产精品~~牛| 日本强好片久久久久久AAA| 久久精品国产99久久久香蕉| 久久久无码精品亚洲日韩蜜臀浪潮| 丁香五月网久久综合| 久久精品国产男包| 香蕉久久夜色精品国产2020| 亚洲国产成人久久综合一| 久久青青草原精品国产| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 亚洲国产另类久久久精品小说| 久久九九久精品国产免费直播| 久久精品国产网红主播| 久久精品国产免费观看| 青春久久| 国产日韩久久免费影院| 久久综合亚洲鲁鲁五月天| 国产99久久精品一区二区| 亚洲精品无码久久久久久| 久久露脸国产精品| 久久久久久毛片免费看| 久久99国产精品99久久| 久久本道伊人久久| 国产99久久久国产精免费| 91久久精品电影| 国产毛片久久久久久国产毛片 | 激情久久久久久久久久| 91精品国产高清久久久久久io|