• <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 閱讀(147) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構與算法

            中文字幕乱码久久午夜| 久久精品成人欧美大片| 亚洲国产高清精品线久久| 怡红院日本一道日本久久 | 伊人久久大香线蕉亚洲| 久久婷婷五月综合国产尤物app| 漂亮人妻被中出中文字幕久久 | 久久综合给合综合久久| 无码国产69精品久久久久网站| 97久久香蕉国产线看观看| 久久成人18免费网站| 久久精品国产精品亚洲精品 | 久久www免费人成精品香蕉| 久久精品国产亚洲AV蜜臀色欲| 国产成人久久精品激情 | 久久99热这里只有精品国产 | 久久久久久av无码免费看大片| 影音先锋女人AV鲁色资源网久久 | 无码乱码观看精品久久| 久久99国产综合精品免费| 精品国产91久久久久久久a| 色综合久久综合中文综合网| 久久综合成人网| 成人国内精品久久久久影院VR| 综合人妻久久一区二区精品| 天天做夜夜做久久做狠狠| 国产精品久久久久久久午夜片| 亚洲国产一成人久久精品 | 欧美亚洲色综久久精品国产| 欧美激情精品久久久久久久九九九| 久久精品国产亚洲AV嫖农村妇女| 最新久久免费视频| 热综合一本伊人久久精品| 精品一久久香蕉国产线看播放| 久久99久久99小草精品免视看| 久久精品国产亚洲AV无码娇色| 伊人色综合久久天天人手人婷 | 久久香蕉一级毛片| 伊人丁香狠狠色综合久久| 国产91色综合久久免费分享| 国产成人综合久久综合|