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

            hdu1075

            What Are You Talking About

            Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)
            Total Submission(s): 6842    Accepted Submission(s): 2086


            Problem Description
            Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book into English. Can you help him?
             

            Input
            The problem has only one test case, the test case consists of two parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should be ignored, then some lines follow, each line contains two strings, the first one is a word in English, the second one is the corresponding word in Martian's language. A line with a single string "END" indicates the end of the directory part, and this string should be ignored. The book part starts with a single line contains a string "START", this string should be ignored, then an article written in Martian's language. You should translate the article into English with the dictionary. If you find the word in the dictionary you should translate it and write the new word into your translation, if you can't find the word in the dictionary you do not have to translate it, and just copy the old word to your translation. Space(' '), tab('\t'), enter('\n') and all the punctuation should not be translated. A line with a single string "END" indicates the end of the book part, and that's also the end of the input. All the words are in the lowercase, and each word will contain at most 10 characters, and each line will contain at most 3000 characters.
             

            Output
            In this problem, you have to output the translation of the history book.
             

            Sample Input
            START from fiwo hello difh mars riwosf earth fnnvk like fiiwj END START difh, i'm fiwo riwosf. i fiiwj fnnvk! END
             

            Sample Output
            hello, i'm from mars. i like earth! 好開心,125ms,statistic里面第三,happying……
            第二個trie,雖然調(diào)了老半天,是些字符串處理的錯誤
            wa了兩邊,原因是count是用來判斷有無該單
            #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>
            #define pp printf("here\n")
            using namespace std;
            struct node
            {
                
            int next[26];
                
            char name[11];
                
            int count;
                
            void init()
                
            {
                    memset(next,
            -1,sizeof(next));
                    count
            =0;
                }

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

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

                    
            //s[ind].count++;
                    ind=s[ind].next[j];
                }

                s[ind].count
            ++;
                len
            =strlen(str1);
                
            for(i=0; i<len; i++)  s[ind].name[i]=str1[i];
                s[ind].name[len]
            ='\0';
            }

            int search(char str[])
            {
                
            int ind,i,j,len=strlen(str);
                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];
                }

                
            return ind;
            }

            int main()
            {
                
            int i,j,len,tmp,ai,k;
                cas_init();
                
            char str[36],str11[15],strn[15];
                
            char str1[1005],str2[10050];
                gets(str);
                
            while(gets(str)&&!(strcmp(str,"END")==0)) 
                
            {
                    len
            =strlen(str);
                    i
            =0;
                    
            while(i<len&&str[i]!=' '{str11[i]=str[i];i++;}str11[i]='\0';
                    i
            ++;
                    j
            =i;
                    
            while(j<len){strn[j-i]=str[j];j++;}strn[j-i]='\0';
                
            //    puts(strn);puts(str11);
                    ins(strn,str11);

                }

                gets(str);
                
            while(gets(str1)&&(strcmp(str1,"END")!=0))
                
            {
                    len
            =strlen(str1);
                    i
            =0;
                    j
            =0;
                    ai
            =0;
                    
            while(j!=len)
                    
            {
                        
            while((str1[i]<'a'||str1[i]>'z')&&(i<len))
                        
            {
                            str2[ai]
            =str1[i];
                            ai
            ++;i++;
                        }

                        j
            =i;
                        
            while(str1[j]<='z'&&str1[j]>='a'&&j<len)
                        
            {
                            strn[j
            -i]=str1[j];
                            j
            ++;
                        }

                        strn[j
            -i]='\0';
                        i
            =j;
                        tmp
            =search(strn);
                        
            if(tmp!=0&&s[tmp].count>0)
                        
            {
                            
            for(k=0; k<strlen(s[tmp].name); k++)
                            
            {
                                str2[ai]
            =s[tmp].name[k];
                                ai
            ++;
                            }

                        }

                        
            else 
                        
            {
                            
            for(k=0;k<strlen(strn);k++)
                            
            {
                                str2[ai]
            =strn[k];
                                ai
            ++;
                            }

                        }

                    }

                    str2[ai]
            ='\0';
                    puts(str2);
                }

                
            return 0;
            }


            posted on 2012-07-16 00:38 jh818012 閱讀(206) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


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

            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當(dāng)于是 取余3的意思 因為 3 的 二進(jìn)制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
            • --王私江
            久久精品国产亚洲麻豆| 7777精品伊人久久久大香线蕉 | 国产激情久久久久久熟女老人| 久久综合给合久久国产免费| 午夜精品久久久内射近拍高清| 久久精品一区二区三区不卡| 久久人人妻人人爽人人爽| 久久精品国产免费观看三人同眠| 久久久久无码中| 国内精品久久久久久久涩爱| 国产L精品国产亚洲区久久| 中文字幕久久欲求不满| 99久久精品午夜一区二区| 99精品久久久久久久婷婷| 亚洲AV无码久久精品蜜桃| 麻豆一区二区99久久久久| 久久人人爽人人爽人人片AV不| 亚洲精品无码成人片久久| 精品国产VA久久久久久久冰| 国产一区二区三区久久| 久久国产视频99电影| 2020国产成人久久精品| 国产精品99久久99久久久| 久久成人影院精品777| 国产ww久久久久久久久久| 久久精品国产只有精品66| 久久婷婷是五月综合色狠狠| 性高湖久久久久久久久| 99国产欧美精品久久久蜜芽| 国产福利电影一区二区三区久久久久成人精品综合 | 91精品国产综合久久精品| 91麻精品国产91久久久久| 久久久久国色AV免费观看| 亚洲精品无码久久千人斩| 国产精品成人无码久久久久久 | 亚洲AV无一区二区三区久久| 久久精品9988| 亚洲国产成人久久精品99| 88久久精品无码一区二区毛片| 久久天天躁狠狠躁夜夜av浪潮| 日日躁夜夜躁狠狠久久AV|