• <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 閱讀(423) 評論(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 
            久久人妻AV中文字幕| www.久久热.com| 青春久久| 亚洲精品99久久久久中文字幕| 久久精品国产99久久丝袜| 久久九九久精品国产| 亚洲国产婷婷香蕉久久久久久| 亚洲一级Av无码毛片久久精品| 久久久一本精品99久久精品88| 国产成人久久精品麻豆一区| 日产精品久久久久久久| 久久人人爽人人爽人人AV东京热| 久久99精品国产麻豆蜜芽| 久久无码AV中文出轨人妻| 久久精品国产精品青草| 三级片免费观看久久| 久久国产色AV免费看| 人人狠狠综合久久亚洲高清| 国产产无码乱码精品久久鸭| 久久综合亚洲色HEZYO社区| 久久伊人亚洲AV无码网站| 91精品国产高清久久久久久国产嫩草| 尹人香蕉久久99天天拍| 久久久久97国产精华液好用吗| A狠狠久久蜜臀婷色中文网| 一个色综合久久| 久久亚洲国产成人影院网站| 久久综合久久综合九色| 久久久久久国产精品免费无码 | 欧美综合天天夜夜久久| 久久久久亚洲av成人网人人软件 | 久久无码人妻一区二区三区午夜| 久久精品国产一区二区| 国产福利电影一区二区三区久久老子无码午夜伦不 | 国产亚洲精久久久久久无码| 日本欧美国产精品第一页久久| 99久久国产综合精品网成人影院 | 亚洲国产成人久久综合野外| 久久99精品国产麻豆不卡| 久久久久久亚洲精品无码| 久久精品国产亚洲5555|