• <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次都沒有想起來是我用了輸入輸出流的原因..
            后來看了討論才想起來...
            呃.這題代碼寫的有點(diǎn)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)  編輯 收藏 引用 所屬分類: 數(shù)據(jù)結(jié)構(gòu)與算法

            四虎国产精品成人免费久久| 亚洲中文久久精品无码ww16| 精品午夜久久福利大片| 777米奇久久最新地址| 国产精品欧美久久久久天天影视| 性做久久久久久久久久久| 精产国品久久一二三产区区别| 色诱久久久久综合网ywww| 嫩草影院久久国产精品| 色偷偷88欧美精品久久久| 99久久精品国产高清一区二区 | 精品久久久无码人妻中文字幕| 久久国产色AV免费观看| 久久久久亚洲精品无码网址 | 亚洲人成伊人成综合网久久久| 国产精品久久久久久吹潮| 中文字幕无码久久人妻| 亚洲一区中文字幕久久| 久久久一本精品99久久精品88| 久久国产精品无码网站| 久久免费小视频| 人妻久久久一区二区三区| 无码国内精品久久人妻麻豆按摩 | 99久久精品免费国产大片| 亚洲中文字幕久久精品无码APP | 97久久久久人妻精品专区 | 91久久精品国产免费直播| 无码人妻精品一区二区三区久久久 | 中文精品久久久久国产网址| 人妻丰满AV无码久久不卡| 久久精品亚洲AV久久久无码| 久久最新免费视频| 久久涩综合| 久久亚洲欧洲国产综合| 久久精品国产清自在天天线| 久久精品免费观看| 国产99久久精品一区二区| 好久久免费视频高清| 99久久精品国产免看国产一区| 久久精品国产99久久久| 久久久精品2019免费观看|