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

            久久综合狠狠综合久久激情 | 久久久久久午夜精品| 国产精品久久久99| 久久se精品一区二区| 青青青青久久精品国产| 久久香蕉一级毛片| 久久www免费人成看国产片| 国产精品美女久久久久AV福利| 99久久99久久精品国产片| 国产精品99久久久久久猫咪| 久久精品无码av| 99久久国产综合精品女同图片 | 亚洲人成网站999久久久综合| 亚洲国产成人久久综合区| 伊人久久大香线蕉av不卡| 性欧美丰满熟妇XXXX性久久久 | 久久亚洲高清综合| 久久99久国产麻精品66| 久久99国产综合精品免费| 99久久免费只有精品国产| 久久综合伊人77777| 伊人久久大香线蕉综合Av| 青青草国产精品久久久久| 久久综合色老色| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 久久国产热这里只有精品| 久久婷婷五月综合97色直播| 欧洲精品久久久av无码电影| 精品久久久久久无码免费| 人妻精品久久无码区| 久久综合九色欧美综合狠狠 | 韩国免费A级毛片久久| 久久久久这里只有精品| 久久精品国产亚洲av麻豆色欲 | 久久香蕉国产线看观看精品yw| 久久久久久综合一区中文字幕| 久久伊人色| 激情五月综合综合久久69| 久久无码人妻一区二区三区 | 久久综合九色综合久99 | 亚洲精品无码久久久影院相关影片|