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

            P3274

            hash.同余.不過這里的同余不是普通意義上的同余.

            #include <iostream>
            #include 
            <fstream>
            using namespace std;
            //ifstream fin("1.txt");
            const int MAXN=100001;
            const int mod=99991;
            int n,k;
            int c[MAXN][30];
            int d[MAXN][30];
            int h[mod];
            int p[MAXN],len=0;
            int s[MAXN];
            int result=0;
            inline 
            int hashcode(const int id)
             
            {
                
            int s = 0;
                
            for(int i=0; i<k; i++)
                    s
            =((s<<2)+(d[id][i]>>4))^(d[id][i]<<10);
                 s 
            = s % mod;
                s 
            = s < 0 ? s + mod : s;
                
            return s;
             }



            void find_hash(int x,int id)
            {
              
            int f[30];
              
            bool ok=true;
              
            for (int i=0;i<k;i++)
              
            {
               
            if (i==0) f[i]=c[id][i]-c[p[x]][i];
               
            else
               
            {
                f[i]
            =c[id][i]-c[p[x]][i];
                
            if (f[i]!=f[i-1]||f[i]==0{ok=false;break;}
               }

              }

              
            if (ok)
              
            {
               
            if (result<id-p[x]) 
               
            {
               result
            =id-p[x];
               }

              }

              
            if (s[x]==-1)
              
            {
               len
            ++;
               s[x]
            =len;
               s[len]
            =-1;
               p[len]
            =id;
               
            return;
              }

              
            else
              
            {
               find_hash(s[x],id);
              }

            }

            void hash(int u,int id)
            {
                 
            if (h[u]==-1)
                 
            {
                  len
            ++;
                  h[u]
            =len;
                  s[len]
            =-1;
                  p[len]
            =id;
                  
            return;
                 }

                 find_hash(h[u],id);
            }

            int main()
            {
                cin
            >>n>>k;
               
            if (n==1{cout<<1<<endl;exit(0);}
                memset(h,
            -1,sizeof(h));
                memset(c,
            0,sizeof(c));
                
            for (int i=1;i<=n;i++)
                
            {
                 
            int x;
                 cin
            >>x;
                 
            int l=-1;
                 
            for (int j=0;j<k;j++)
                 
            {
                  
            int p=x%2;
                  l
            ++;
                  c[i][l]
            =c[i-1][l]+p;
                  x
            /=2;
                 }

                }

                
                memcpy(d,c,
            sizeof(c));
                
            for (int i=0;i<=n;i++)
                
            {
                 
            int max=MAXN;
                 
            for (int j=0;j<k;j++)
                 
            {
                     
            if (max>d[i][j]) max=d[i][j];
                 }

                 
            for (int j=0;j<k;j++)
                 
            {
                     d[i][j]
            -=max;
                 }

                 
            int u=hashcode(i);
                 
            //cout<<u<<endl;
                 hash(u,i);
                }

                
                
                cout
            <<result<<endl;
              
            //  system("pause");
                return 0;
            }

            posted on 2009-10-21 12:46 Vincent 閱讀(162) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構與算法

            99久久99这里只有免费的精品| 性做久久久久久久久久久| 久久精品天天中文字幕人妻| 久久99精品久久久久婷婷| 国产高潮国产高潮久久久91| 亚洲精品无码久久久| 久久精品中文字幕无码绿巨人| 热久久国产精品| 99久久精品免费看国产一区二区三区 | 国内精品久久久久影院免费| 久久精品视屏| 久久亚洲精品国产亚洲老地址| 久久综合亚洲鲁鲁五月天| 久久电影网一区| 亚洲国产精品无码久久久蜜芽| 久久综合成人网| 91精品国产色综久久| 久久夜色精品国产噜噜噜亚洲AV| 国产一区二区精品久久岳| 国产人久久人人人人爽| 97精品依人久久久大香线蕉97| 久久精品国产一区二区三区| 欧美久久综合性欧美| 粉嫩小泬无遮挡久久久久久| 蜜桃麻豆WWW久久囤产精品| 欧美国产精品久久高清| 成人亚洲欧美久久久久| 四虎国产永久免费久久| 精品久久久久香蕉网| 久久精品国产亚洲av日韩| 亚洲精品美女久久久久99| 97久久婷婷五月综合色d啪蜜芽| 午夜精品久久影院蜜桃| 婷婷国产天堂久久综合五月| 亚洲国产成人久久综合野外| 久久久久亚洲精品天堂久久久久久| 日本道色综合久久影院| 久久av高潮av无码av喷吹| 久久久久国产精品嫩草影院 | 国产精品久久影院| 国产精品免费福利久久|