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

            superman

            聚精會神搞建設(shè) 一心一意謀發(fā)展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            ZOJ 1109 - Language of FatMouse

            Posted on 2008-04-01 19:49 superman 閱讀(428) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ
            This implement use the map in STL.
             1 /* Accepted 1109 C++ 00:04.47 7992K */
             2 #include <map>
             3 #include <string>
             4 #include <iostream>
             5 
             6 using namespace std;
             7 
             8 int main()
             9 {
            10     map <stringstring> dict;
            11     
            12     int n = 0string s;
            13     while(true)
            14     {
            15         getline(cin, s);
            16         if(s == "")
            17             break;
            18         
            19         string a, b; int i;
            20         for(i = 0; s[i] != ' '; i++)
            21             a += s[i];
            22         for(i = i + 1; i < s.size(); i++)
            23             b += s[i];
            24         dict[b] = a;
            25     }
            26     
            27     while(cin >> s)
            28     {
            29         if(dict.count(s))
            30             cout << dict[s] << endl;
            31         else
            32             cout << "eh" << endl;
            33     }
            34     
            35     return 0;
            36 }
            37 

            This implement use quicksort and binay search.
             1 /* Accepted 1109 C++ 00:04.34 6408K */
             2 #include <string>
             3 #include <stdlib.h>
             4 #include <iostream>
             5 
             6 using namespace std;
             7 
             8 struct DICT { string en, mouse; } dict[100005];
             9 
            10 int cmp(const void * a, const void * b)
            11 {
            12     DICT * c = (DICT *) a;
            13     DICT * d = (DICT *) b;
            14     return (c -> mouse < d -> mouse ? -1 : 1);
            15 }
            16 
            17 int main()
            18 {
            19     int n = 0string s;
            20     while(true)
            21     {
            22         getline(cin, s);
            23         if(s == "")
            24             break;
            25         int i;
            26         for(i = 0; s[i] != ' '; i++)
            27             dict[n].en += s[i];
            28         for(i++; i < s.size(); i++)
            29             dict[n].mouse += s[i];
            30         n++;
            31     }
            32     
            33     qsort(dict, n, sizeof(DICT), cmp);
            34     
            35     while(cin >> s)
            36     {
            37         int l = 0, mid, r = n - 1, find = 0;
            38         while(l <= r)
            39         {
            40             mid = (l + r) / 2;
            41             if(dict[mid].mouse == s)
            42             {
            43                 find = 1;
            44                 break;
            45             }
            46             if(dict[mid].mouse < s)
            47                 l = mid + 1;
            48             else
            49                 r = mid - 1;
            50         }
            51         if(find)
            52             cout << dict[mid].en << endl;
            53         else
            54             cout << "eh" << endl;
            55     }
            56     
            57     return 0;
            58 }
            59 
            欧美久久久久久午夜精品| 久久影院亚洲一区| 一本一本久久a久久精品综合麻豆| 久久久久久一区国产精品| 亚洲国产成人久久综合野外| 日日狠狠久久偷偷色综合96蜜桃| 亚洲午夜福利精品久久 | 久久精品国产亚洲AV麻豆网站 | 久久人人爽人人人人片av| 国产精品亚洲综合久久| 久久se精品一区二区| 亚洲人成无码网站久久99热国产| 久久这里只有精品久久| 婷婷国产天堂久久综合五月| 国内精品久久久久久麻豆| 久久天天躁狠狠躁夜夜96流白浆| 久久久久无码国产精品不卡| 国产成人久久精品麻豆一区| 国产精品久久久久一区二区三区| 久久精品aⅴ无码中文字字幕重口| 久久婷婷色综合一区二区 | 久久九九精品99国产精品| 亚洲香蕉网久久综合影视| 伊人色综合久久天天人守人婷| 久久精品亚洲男人的天堂| 色8久久人人97超碰香蕉987| 狠狠狠色丁香婷婷综合久久俺| 热re99久久精品国产99热| 久久亚洲精品无码观看不卡| 日韩人妻无码一区二区三区久久99| 久久久久久久综合狠狠综合| 久久亚洲精品成人AV| 久久精品综合网| 精品国产一区二区三区久久| 久久国产精品偷99| 91久久九九无码成人网站| 中文字幕乱码人妻无码久久| 久久久久亚洲av成人无码电影| 婷婷久久久亚洲欧洲日产国码AV| 久久精品国产免费一区| 亚洲精品乱码久久久久久蜜桃图片|