• <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>

            hdu1247

            Hat’s Words

            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
            Total Submission(s): 3224    Accepted Submission(s): 1223


            Problem Description
            A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.
            You are to find all the hat’s words in a dictionary.
             

            Input
            Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will be no more than 50,000 words.
            Only one case.
             

            Output
            Your output should contain all the hat’s words, one per line, in alphabetical order.
             

            Sample Input
            a ahat hat hatword hziee word
             

            Sample Output
            ahat hatword
             
            尼瑪傷不起啊,分明是個模版題,結果寫錯初始化了,sind應該是1,寫成了0,我擦
            浪費我四十分鐘,害我wa6遍,我擦
            #include <cstdio>
            #include 
            <cstdlib>
            #include 
            <cstring>
            #include 
            <cmath>
            #include 
            <ctime>
            #include 
            <cassert>
            #include 
            <iostream>
            #include 
            <sstream>
            #include 
            <fstream>
            #include 
            <map>
            #include 
            <set>
            #include 
            <vector>
            #include 
            <queue>
            #include 
            <algorithm>
            #include 
            <iomanip>
            using namespace std;
            #include
            <string.h>
            #define maxl 105
            struct node
            {
                
            int next[26];
                
            int count;
                
            void init()
                
            {
                    memset(next,
            -1,sizeof(next));
                    count
            =0;
                }

            }
             s[5000005];
            char ss[50005][maxl];
            //char ss1[50005][maxl];
            /*struct node1
            {
                char s[16];
            }ans[50005];
            */

            int num;
            int sind,n;
            void cas_init()
            {
                s[
            0].init();
                sind
            =1;
            }

            /*int cmp(node1 ch1,node1 ch2)
            {
                return strcmp(ch1.s,ch2.s)<0;
            }
            */

            void ins(char str[])
            {
                
            int len=strlen(str);
                
            int i,j,ind;
                ind
            =0;
                
            for(i=0; i<len; i++)
                
            {
                    j
            =str[i]-'a';
                    
            if(s[ind].next[j]==-1)
                    
            {
                        s[sind].init();
                        s[ind].next[j]
            =sind++;
                    }

                    ind
            =s[ind].next[j];
                }

                s[ind].count
            ++;
            }

            int search(char str[])
            {
                
            int len=strlen(str);
                
            int ind,i,j;
                ind
            =0;
                
            for(i=0; i<len; i++)
                
            {
                    j
            =str[i]-'a';
                    
            if(s[ind].next[j]==-1)
                        
            return 0;
                    
            else ind=s[ind].next[j];
                }

               
            if(s[ind].count>0return 1;
               
            else return 0;
            }

            int main()
            {
                
            char str[maxl],str1[maxl],str2[maxl];
                cas_init();
                n
            =0;
              
            //  freopen("in1.txt","r+",stdin);
                while(scanf("%s",ss[n])!=EOF)
                
            {
                    ins(ss[n]);
                    n
            ++;
                }

                
            //int flag;
                int i,j,k;
                num
            =0;
                
            for(i=0; i<n; i++)
                
            {
                    
            //flag=0;
                    if(strlen(ss[i])==1continue;
                    
            int len=strlen(ss[i]);
                    
            //printf("%d\n",len-1);
                    for(j=1; j<=len-1; j++)
                    
            {
                        
            for(k=0; k<j; k++) str1[k]=ss[i][k];
                        str1[k]
            ='\0';
                        
            for(k=j; k<len; k++) str2[k-j]=ss[i][k];
                        str2[k
            -j]='\0';
                        
            //puts(str1);
                        
            //puts(str2);
                        if(search(str1)&&search(str2))
                        
            {
                            
            //flag=1;
                            
            //strcpy(ans[num++].s,ss[i]);
                            
            //strcpy(ss1[num++],ss[i]);
                            printf("%s\n",ss[i]);
                            
            break;
                        }

                    }

                }

            //    sort(ans,ans+num,cmp);
                
            //for(i=0;i<num;i++)
                {
                    
            //printf("%s\n",ans[i].s);
                
            //    puts(ss[i]);
                }

              
            // fclose(stdin);
                return 0;
            }



            /////尼瑪,調半天都沒調出來,浪費40分鐘

            posted on 2012-07-16 15:12 jh818012 閱讀(214) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            久久国产精品久久久| 亚洲国产美女精品久久久久∴| jizzjizz国产精品久久| 国产精品久久永久免费| 精品久久久久久国产三级| 久久人妻少妇嫩草AV无码蜜桃| 久久久久国产| AV无码久久久久不卡蜜桃| 久久久中文字幕日本| 色综合久久无码中文字幕| 国产精品内射久久久久欢欢| 久久久久久国产精品美女| 国产精品久久久久9999| 中文字幕精品久久| 国产99久久久国产精免费| 无码日韩人妻精品久久蜜桃| 久久99精品国产麻豆婷婷| 精品久久久久久无码中文字幕一区| 99久久精品无码一区二区毛片 | 久久中文娱乐网| 久久亚洲国产精品成人AV秋霞| 久久久久久免费一区二区三区| 国产色综合久久无码有码| 亚洲精品乱码久久久久久蜜桃 | 久久综合伊人77777| 国产精品久久久久aaaa| 久久天天躁狠狠躁夜夜96流白浆 | 久久亚洲精品中文字幕| 久久久噜噜噜久久| 精品久久人人爽天天玩人人妻| 久久精品国产清高在天天线| 亚洲国产美女精品久久久久∴| 四虎国产精品成人免费久久 | 色综合久久久久久久久五月| 亚洲国产视频久久| 亚洲精品午夜国产va久久| 伊人 久久 精品| 久久夜色精品国产噜噜亚洲a| 日韩久久久久中文字幕人妻| 久久久久久青草大香综合精品 | 久久亚洲AV成人无码电影|