• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            題目大意:一些相同的01串被打碎成兩半,現(xiàn)在給出這些打碎了之后的串,要求求出原串。
            首先,原串的長度一定是打碎了之后的串中最長的長度加上最短的長度。設(shè)打碎之后的串中最長串組成集合S,最短串組成集合T,那么原串肯定為ST或TS中的某種。由于S、T中元素個數(shù)必定小于等于2,所以可能的結(jié)果最多只有8種。枚舉這8種結(jié)果,然后檢測是否符合要求即可。
            檢測的時候,對于某個長度為L的串,要快速檢索到長度為(maxlength+minlength-L)的串,使用multimap<int,string>可以很方便地做到。
            以下是我的代碼:
            #include<iostream>
            #include
            <vector>
            #include
            <string>
            #include
            <map>
            #include
            <algorithm>
            #include
            <cstdio>
            using namespace std;

            bool cmp(const string &a,const string &b)
            {
                
            return (a.size()<b.size() ||(a.size()==b.size() && a<b));
            }

            int main()
            {
                #ifndef ONLINE_JUDGE
                freopen(
            "data.in","r",stdin);
                freopen(
            "data.out","w",stdout);
                
            #endif

                
            int T;
                cin
            >>T;
                cin.
            get();
                cin.
            get();
                
            bool first(true);
                
            while(T--)
                {
                    
            int minl(0x7f7f7f7f),maxl(0);
                    vector
            <string> a;
                    
            string t;
                    
            while(getline(cin,t) && !t.empty())
                    {
                        a.push_back(t);
                        minl
            =min(minl,(int)(t.size()));
                        maxl
            =max(maxl,(int)(t.size()));
                    }

                    sort(a.begin(),a.end(),cmp);
                    a.erase(unique(a.begin(),a.end()),a.end());

                    multimap
            <int,string> r;
                    
            for(int i=0;i<a.size();i++)
                        r.insert(make_pair(a[i].size(),a[i]));

                    
            string ans;
                    multimap
            <int,string>::iterator
                        ibegin
            =r.begin(),
                        iend
            =r.upper_bound(minl),
                        jend
            =r.end(),
                        jbegin
            =r.lower_bound(maxl);
                    
            for(multimap<int,string>::iterator i=ibegin;i!=iend;i++)
                        
            for(multimap<int,string>::iterator j=jbegin;j!=jend;j++)
                        {
                            
            string now(i->second+j->second);
                            
            bool success(true);
                            
            for(multimap<int,string>::iterator k=r.begin();k!=r.end();k++)
                            {
                                multimap
            <int,string>::iterator
                                    pbegin
            =r.lower_bound(minl+maxl-k->first),
                                    pend
            =r.upper_bound(minl+maxl-k->first);
                                
            bool can(false);
                                
            for(multimap<int,string>::iterator l=pbegin;l!=pend;l++)
                                {
                                    
            if(k->second+l->second==now || l->second+k->second==now)
                                        can
            =true;
                                }
                                
            if(!can)
                                {
                                    success
            =false;
                                    
            break;
                                }
                            }
                            
            if(success)
                                ans
            =now;

                            now
            =j->second+i->second;
                            success
            =true;
                            
            for(multimap<int,string>::iterator k=r.begin();k!=r.end();k++)
                            {
                                multimap
            <int,string>::iterator
                                    pbegin
            =r.lower_bound(minl+maxl-k->first),
                                    pend
            =r.upper_bound(minl+maxl-k->first);
                                
            bool can(false);
                                
            for(multimap<int,string>::iterator l=pbegin;l!=pend;l++)
                                {
                                    
            if(k->second+l->second==now || l->second+k->second==now)
                                        can
            =true;
                                }
                                
            if(!can)
                                {
                                    success
            =false;
                                    
            break;
                                }
                            }
                            
            if(success)
                                ans
            =now;
                        }

                    
            if(first)
                        first
            =false;
                    
            else
                        cout
            <<endl;
                    cout
            <<ans<<endl;
                }

                
            return 0;
            }
            中文国产成人精品久久不卡| 精品国产乱码久久久久软件 | 伊人久久大香线蕉精品不卡 | 久久亚洲精品中文字幕三区| 91精品国产综合久久婷婷| 热久久国产精品| 欧美久久久久久精选9999| 99久久无色码中文字幕人妻| 91久久福利国产成人精品| 蜜桃麻豆WWW久久囤产精品| 精品免费久久久久久久| 色婷婷噜噜久久国产精品12p| 精品一二三区久久aaa片| 亚洲一区二区三区日本久久九| 欧美精品福利视频一区二区三区久久久精品 | 亚洲国产精品成人久久蜜臀 | 蜜臀久久99精品久久久久久小说 | 久久频这里精品99香蕉久| 国产精品久久久久影视不卡| 亚洲国产成人久久综合碰| 嫩草影院久久99| 精品久久久久久成人AV| 亚洲伊人久久综合影院| 国产精品热久久无码av| 久久国产精品-久久精品| 97久久婷婷五月综合色d啪蜜芽| 超级碰久久免费公开视频| 久久青青草原亚洲av无码app| 亚洲精品成人久久久| 久久亚洲2019中文字幕| 久久电影网一区| 婷婷久久综合九色综合98| 午夜精品久久久久久99热| 久久久久高潮综合影院| 中文字幕无码久久精品青草| 久久精品成人免费观看97| 久久精品无码一区二区日韩AV| 蜜桃麻豆www久久| 久久婷婷久久一区二区三区| 国产韩国精品一区二区三区久久 | 久久久国产精品亚洲一区|