• <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 
            久久久婷婷五月亚洲97号色 | 亚洲人成精品久久久久| 人妻无码久久精品| 亚洲乱码中文字幕久久孕妇黑人| 久久久久久亚洲精品成人| 久久精品中文字幕久久| 久久99热狠狠色精品一区| 久久天天躁狠狠躁夜夜2020老熟妇 | 国产视频久久| 无码精品久久久久久人妻中字| 大伊人青草狠狠久久| 亚洲va久久久久| 久久久久夜夜夜精品国产| 亚洲一级Av无码毛片久久精品| 国内精品久久人妻互换| 久久久久亚洲精品无码蜜桃| 国産精品久久久久久久| 色综合久久无码中文字幕| 久久久久久青草大香综合精品| 国产精品久久久久国产A级| 天天综合久久一二三区| 国产精品日韩欧美久久综合| 国内精品久久久人妻中文字幕| 狠狠色丁香婷婷久久综合| 精品综合久久久久久88小说| 丁香狠狠色婷婷久久综合| 国产精品久久久久久搜索| 久久精品aⅴ无码中文字字幕重口| 亚洲精品乱码久久久久久不卡| 99久久精品无码一区二区毛片| 一本色道久久88加勒比—综合| 久久婷婷国产综合精品| 精品久久久中文字幕人妻| 久久久久久无码国产精品中文字幕 | 伊人久久大香线蕉综合5g| 久久精品国产精品亚洲人人| 久久国产精品久久| 久久狠狠色狠狠色综合| 亚洲国产二区三区久久| 国产午夜福利精品久久| 久久黄视频|