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

            聚精會神搞建設 一心一意謀發展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            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 
            久久99久久成人免费播放| 亚洲中文字幕无码久久2020| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 久久99热这里只有精品国产 | 久久人爽人人爽人人片AV | 国内精品综合久久久40p| 精品熟女少妇av免费久久| 无码精品久久一区二区三区| 久久久久亚洲AV片无码下载蜜桃 | 国产激情久久久久影院小草 | 91久久精品91久久性色| 亚洲а∨天堂久久精品| 99久久99久久久精品齐齐| 亚洲精品无码久久毛片| 国产高清美女一级a毛片久久w | 久久人做人爽一区二区三区| 狠狠色丁香久久综合婷婷| 亚洲伊人久久大香线蕉综合图片| 91亚洲国产成人久久精品网址| 欧美亚洲色综久久精品国产| 久久精品桃花综合| 久久综合九色综合久99| 国产精自产拍久久久久久蜜| 大伊人青草狠狠久久| 欧美丰满熟妇BBB久久久| 伊人久久无码精品中文字幕| 色婷婷久久久SWAG精品| 久久久久九国产精品| 久久AⅤ人妻少妇嫩草影院| 99久久精品九九亚洲精品| 日本福利片国产午夜久久| 久久久国产精品网站| 久久免费精品视频| 国产国产成人久久精品| 久久精品无码免费不卡| 久久久久久A亚洲欧洲AV冫| 久久久久18| 久久精品国产亚洲AV不卡| 久久99精品久久久久久久不卡 | 少妇久久久久久久久久| 国产亚洲色婷婷久久99精品|