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

            综合久久一区二区三区| 亚洲精品无码成人片久久| 久久永久免费人妻精品下载| 久久99精品国产99久久| 久久夜色精品国产| www性久久久com| 久久久久久曰本AV免费免费| 日产精品久久久久久久| 国产精品久久久久影院色| 久久亚洲精品国产精品婷婷| 青青草国产成人久久91网| 亚洲va久久久噜噜噜久久狠狠 | 久久亚洲精品成人AV| 亚洲午夜久久影院| 久久99国产精品尤物| 亚洲午夜福利精品久久| 国产精品久久国产精品99盘| 青青草国产97免久久费观看| 嫩草影院久久99| 18岁日韩内射颜射午夜久久成人| 久久av高潮av无码av喷吹| 久久国产精品久久精品国产| 亚洲国产成人久久综合碰| 777久久精品一区二区三区无码| 亚洲AV日韩精品久久久久久久| 国产精品丝袜久久久久久不卡| 国产精品午夜久久| 99久久精品国产高清一区二区 | 97久久超碰国产精品2021| 亚洲国产成人乱码精品女人久久久不卡 | 久久久久国产精品人妻| 亚洲国产精品无码久久九九| 久久亚洲国产精品123区| 国产成人精品久久亚洲| 国产欧美一区二区久久| 精品熟女少妇a∨免费久久| 久久精品国产亚洲AV电影| 久久香蕉国产线看观看99| 人妻久久久一区二区三区| 亚洲精品乱码久久久久久按摩 | 国产99久久久国产精品小说|