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

            P2676

            老老老老老題..能繼續剪枝的..但是我懶..
            就不剪了..
            1y.我喜歡木陷阱的題...

            #include <iostream>
            #include 
            <vector>
            using namespace std;

            int c[10][10];
            int ca;
            struct node
            {      
                   
            int x,y,value;
            }
            ;
            vector
            <node> v;
            bool h[10][10],l[10][10];
            bool mat[10][10];
            bool ok;

            int getPos(int x,int y)
            {
                
            return (x-1)/3*3+(y-1)/3+1;
            }

            void dfs(int pos)
            {
             
            if (pos==v.size())
             
            {
              
            for (int i=1;i<=9;i++)
              
            {
               
            for (int j=1;j<=9;j++)
               
            {
                cout
            <<c[i][j];
               }

               cout
            <<endl;
              }

              ok
            =true;
              
            return;
             }

             
             node p
            =v[pos];
             
            int x=p.x;
             
            int y=p.y;
             
            for (int i=1;i<=9&&(!ok);i++)
             
            {
              
            if (h[x][i]) continue;
              
            if (l[i][y]) continue;
              
            if (mat[getPos(x,y)][i]) continue;
              h[x][i]
            =true;
              l[i][y]
            =true;
              mat[getPos(x,y)][i]
            =true;
              c[x][y]
            =i;
              dfs(pos
            +1);
              h[x][i]
            =false;
              l[i][y]
            =false;
              mat[getPos(x,y)][i]
            =false;
             }

            }

            int main()
            {
                
                cin
            >>ca;
                
            while(ca--)
                
            {
                 v.clear();
                 memset(h,
            false,sizeof(h));
                 memset(l,
            false,sizeof(l));
                 memset(mat,
            false,sizeof(mat));
                 ok
            =false;
                 
            char ch;
                 
            for (int i=1;i<=9;i++)
                  
            for (int j=1;j<=9;j++)
                  
            {
                   cin
            >>ch;
                   c[i][j]
            =ch-'0';
                   
            if (c[i][j]==0)
                   
            {
                    node p;
                    p.x
            =i;
                    p.y
            =j;
                    p.value
            =0;
                    v.push_back(p);
                   }

                   
            else
                   
            {
                    h[i][c[i][j]]
            =true;
                    l[c[i][j]][j]
            =true;
                    mat[getPos(i,j)][c[i][j]]
            =true;
                   }

                   
                  }

                  dfs(
            0);
                
            // solve();
                }

                
            //system("pause");
                return 0;
            }

            posted on 2009-11-04 12:50 Vincent 閱讀(137) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構與算法

            97超级碰碰碰久久久久| 久久久国产精品福利免费| 久久久久国产精品三级网| 99久久香蕉国产线看观香| 久久免费的精品国产V∧| 99久久国产亚洲高清观看2024| 久久久久久青草大香综合精品| 午夜天堂精品久久久久| 久久99久久无码毛片一区二区| 综合网日日天干夜夜久久| 国产成人香蕉久久久久| 婷婷久久久亚洲欧洲日产国码AV| Xx性欧美肥妇精品久久久久久| 亚洲av成人无码久久精品| 国产高清国内精品福利99久久| 久久这里只有精品首页| 99久久婷婷国产综合精品草原| 色婷婷综合久久久中文字幕| 亚洲精品视频久久久| 91精品免费久久久久久久久| 久久国产精品99国产精| 久久91精品国产91| 久久久久亚洲国产| 亚洲天堂久久久| 香蕉久久夜色精品国产尤物| 久久久久香蕉视频| 四虎国产精品免费久久5151 | 久久91精品国产91久久户| 色播久久人人爽人人爽人人片AV| 国产福利电影一区二区三区久久久久成人精品综合| 久久亚洲精品无码aⅴ大香| 中文成人久久久久影院免费观看| 久久亚洲精品无码观看不卡| 国产69精品久久久久9999| 伊人久久综合热线大杳蕉下载| 久久九九亚洲精品| 国产亚州精品女人久久久久久| 久久国产成人| 久久91精品国产91久| 77777亚洲午夜久久多人| 久久久亚洲欧洲日产国码二区|