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

            巢穴

            about:blank

            P3080

            枚舉+kmp..再不練kmp都忘了..orz
            wa了一次..注意一下求出的串要最小的那個

            #include <iostream>
            #include 
            <string>
            //#include <fstream>
            using namespace std;
            //ifstream fin("t3080.in");
            const int MAXN=100;
            int k;
            int n;
            string str[MAXN];
            string s_,result;
            int p[MAXN];
            void match_self()
            {
                 memset(p,
            sizeof(p),0);
                 p[
            0]=-1;
                 
            int x=-1;
                 
            for (int i=1;i<s_.length();i++)
                 
            {
                     
            while (x>-1&&s_[x+1]!=s_[i]) x=p[x];
                     
            if (s_[x+1]==s_[i]) x++;
                     p[i]
            =x;
                 }

            }

            bool match(string s)
            {
                 
            int x=-1;
                 
            for (int i=0;i<s.length();i++)
                 
            {
                  
            while (x>-1&&s_[x+1]!=s[i]) x=p[x];
                  
            if (s_[x+1]==s[i]) x++;
                  
            if (x==s_.length()-1return true;
                  
            //p[i]=x;
                 }

                 
            return false;
            }

            int main()
            {
                cin
            >>k;
                
            while(k--)
                
            {
                 cin
            >>n;
                 
            bool ok=false;
                 
            for (int i=1;i<=n;i++)
                 
            {
                     cin
            >>str[i];
                 }

                 
            string st=str[1];
                 
            for (int i=st.length();(i>=3)&&(ok==false);i--)
                 
            {
                  
            for (int j=0;(j<=i+j-1)&&(i+j-1<st.length());j++)
                  
            {
                   s_
            =st.substr(j,i);
                   match_self();
                   
            int count=0;
                   
            for (int k=2;k<=n;k++)
                   
            {
                    
            if (match(str[k])) count++;
                   }

                   
            if (n-1==count)
                   
            {
                    
            if (!ok) result=s_; else if (result>s_) result=s_;
                    ok
            =true;
                   }

                  }

                 }

                 
            if (ok)
                 
            {
                  cout
            <<result<<endl;
                 }

                 
            else
                 
            {
                  cout
            <<"no significant commonalities"<<endl;
                 }

                }

                system(
            "pause");
                
            return 0;
            }

            posted on 2009-10-19 21:30 Vincent 閱讀(89) 評論(0)  編輯 收藏 引用 所屬分類: 數(shù)據(jù)結(jié)構(gòu)與算法

            久久免费视频网站| 久久中文精品无码中文字幕| 欧美日韩久久中文字幕| 久久久精品国产| 久久精品中文字幕无码绿巨人| av国内精品久久久久影院| 亚洲国产成人久久精品动漫| 久久天天躁狠狠躁夜夜2020| 免费精品久久久久久中文字幕| 久久亚洲国产精品成人AV秋霞| 国产成人精品久久| 国产精品日韩欧美久久综合| 狠狠色综合网站久久久久久久高清 | 波多野结衣中文字幕久久| 久久精品国产一区二区 | 久久er国产精品免费观看8| 久久青青色综合| 久久亚洲国产中v天仙www| 久久久久久伊人高潮影院| 久久国产香蕉一区精品| 久久天天躁狠狠躁夜夜躁2O2O| 久久精品中文字幕第23页| 国产精品久久久久久福利漫画 | 亚洲精品无码久久毛片| 久久99精品国产99久久| 一本久久知道综合久久| 久久国产精品无| 久久亚洲国产精品五月天婷| 久久精品国产一区二区三区日韩| 国产69精品久久久久久人妻精品| 久久久久女教师免费一区| 久久综合综合久久97色| 国产精品视频久久久| 久久精品国产亚洲av麻豆色欲| 中文字幕乱码久久午夜| 亚洲а∨天堂久久精品| 久久精品免费网站网| 国产精久久一区二区三区| 91精品国产高清久久久久久国产嫩草 | 亚洲色婷婷综合久久| 麻豆亚洲AV永久无码精品久久|