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

            久久本道久久综合伊人| 久久久精品国产sm调教网站| 97久久超碰国产精品2021| 久久精品99久久香蕉国产色戒| 久久精品无码一区二区无码| 国产午夜精品理论片久久影视 | 久久国产一片免费观看| 久久九九久精品国产| 久久精品国产久精国产一老狼| 亚洲va久久久噜噜噜久久狠狠| 久久91亚洲人成电影网站| 热综合一本伊人久久精品| 久久亚洲春色中文字幕久久久| 热re99久久精品国产99热| 久久婷婷是五月综合色狠狠| 久久国产精品无码HDAV| 综合久久给合久久狠狠狠97色| 久久AV高清无码| 亚洲精品综合久久| 国产免费久久精品丫丫| 久久久久人妻一区二区三区vr| 久久天天躁狠狠躁夜夜不卡| 999久久久无码国产精品| 久久亚洲日韩看片无码| 久久久无码精品午夜| 久久综合中文字幕| 久久精品蜜芽亚洲国产AV| 免费久久人人爽人人爽av| 久久精品国产亚洲Aⅴ香蕉 | 精品久久久久久国产| 久久久91人妻无码精品蜜桃HD| 国产精品久久免费| 久久夜色精品国产网站| 精品国产乱码久久久久软件| 久久亚洲国产精品五月天婷| 青草影院天堂男人久久| 久久精品国产一区二区三区日韩| 久久99精品久久久久久动态图| 欧美日韩精品久久久免费观看| 久久天天躁狠狠躁夜夜avapp| 一本色道久久综合狠狠躁篇|