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

            P3349

            hash..
            tle了2次都沒有想起來是我用了輸入輸出流的原因..
            后來看了討論才想起來...
            呃.這題代碼寫的有點orz
            #include <iostream>
            #include 
            <stdio.h>
            using namespace std;
            const int MAXN=100000;
            const long mod=999991;
            int n;
            long hash[mod];
            long c[7];
            int len=-1;
            struct node
            {
              
            long c[7];
              
            long son;
            }
            ;
            bool isFind=false;
            node list[MAXN];
            int p[13];
            void find_node(long x)
            {
             
            for (int i=1;i<=6;i++)
             
            {
              
            int count=0;
              
            for (int j=i;j<=i+6-1;j++)
              
            {
               
            if (p[j]==list[x].c[j-i+1]) count++;
              }

              
            if (count==6)
              
            {
                isFind
            =true;
                
            return;
              }

              count
            =0;
              
            for (int j=i;j<=i+6-1;j++)
              
            {
               
            if (p[j]==list[x].c[6-(j-i+1)+1]) count++;   
              }

              
            if (count==6)
              
            {
                isFind
            =true;
                
            return;
              }

             }

             
             
            if (list[x].son!=-1) find_node(list[x].son);
             
            else
             
            {
                 len
            ++;
                 list[x].son
            =len;
                 list[len].son
            =-1;
                 
            for (int i=1;i<=6;i++)
                 
            {
                    list[len].c[i]
            =c[i];
                 }

                 
            return;
                 
             }

             
            }

            void find(long x)
            {
                 
            if (hash[x]==-1)
                 
            {
                   len
            ++;
                   hash[x]
            =len;
                   list[len].son
            =-1;
                   
            for (int i=1;i<=6;i++)
                   
            {
                    list[len].c[i]
            =c[i];
                   }

                   
            return;
                 }

                
            // cout<<x<<endl;
                 for (int i=1;i<=6;i++)
                   p[i]
            =c[i];
                 
            for (int i=7;i<=12;i++)
                   p[i]
            =c[i-6];
                 find_node(hash[x]);
            }

            int main()
            {
                scanf(
            "%ld",&n);
                
            for (int i=0;i<mod;i++)
                    hash[i]
            =-1;
               
            // memset(hash,-1,sizeof(hash));
                for (int i=1;i<=n;i++)
                
            {
                    
            long ans=0;
                    
            for (int j=1;j<=6;j++)
                    
            {
                        scanf(
            "%ld",c+j);
                        ans
            +=c[j];
                    }

                    
            long x=ans%mod;
                  
            //  cout<<x<<endl;
                    find(x);
                    
                }

                
            if (isFind) cout<<"Twin snowflakes found."<<endl;
                
            else
                    cout
            <<"No two snowflakes are alike."<<endl;   
                
            //system("pause");
                return 0;
                
            }

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

            久久性精品| 久久中文字幕人妻丝袜| 色偷偷偷久久伊人大杳蕉| 蜜桃麻豆WWW久久囤产精品| 精品久久久中文字幕人妻| 久久精品亚洲一区二区三区浴池| 久久精品国产清高在天天线| 韩国三级中文字幕hd久久精品 | 午夜视频久久久久一区 | 麻豆精品久久久一区二区| 久久99精品国产麻豆蜜芽| 欧美伊人久久大香线蕉综合| 久久天堂AV综合合色蜜桃网| 国产福利电影一区二区三区,免费久久久久久久精 | 国产成人无码精品久久久久免费| 思思久久精品在热线热| 精品久久久久久无码中文字幕一区| 久久国产精品久久| 无码人妻久久久一区二区三区| 亚洲国产精久久久久久久| 精品久久久无码21p发布| 久久久久久久综合日本| 久久91精品国产91久久小草| 精品人妻伦九区久久AAA片69| 精品久久久久久久久久中文字幕 | 国产韩国精品一区二区三区久久 | 美女写真久久影院| 97久久综合精品久久久综合| 久久亚洲精品无码aⅴ大香| 久久夜色精品国产亚洲av| 亚洲乱亚洲乱淫久久| 国产精品久久久久久吹潮| 色婷婷综合久久久中文字幕| 亚洲天堂久久久| 97香蕉久久夜色精品国产 | 久久久久久国产精品无码下载| 久久久久国色AV免费看图片 | 亚洲成色WWW久久网站| 久久天天躁狠狠躁夜夜躁2014| 亚洲欧美成人久久综合中文网| 久久亚洲国产成人影院网站|