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

            老老老老老題..能繼續(xù)剪枝的..但是我懶..
            就不剪了..
            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 閱讀(130) 評論(0)  編輯 收藏 引用 所屬分類: 數(shù)據(jù)結(jié)構(gòu)與算法

            97久久香蕉国产线看观看| 要久久爱在线免费观看| 亚洲日本久久久午夜精品| 久久精品这里只有精99品| 欧美伊人久久大香线蕉综合69| 亚洲欧美成人综合久久久 | 亚洲国产成人久久精品影视| 亚洲天堂久久精品| 日韩电影久久久被窝网| 麻豆成人久久精品二区三区免费| 51久久夜色精品国产| 无码任你躁久久久久久| 国产V综合V亚洲欧美久久| 亚洲国产一成久久精品国产成人综合 | 伊人久久综合无码成人网| 中文字幕亚洲综合久久2| 波多野结衣久久一区二区 | 精品久久国产一区二区三区香蕉| 久久精品国产亚洲AV无码娇色 | 国产亚洲色婷婷久久99精品| 狠狠人妻久久久久久综合| 久久精品国产免费观看三人同眠| 精品久久久久久久久久中文字幕| 国色天香久久久久久久小说| 99久久精品国产综合一区| 99久久精品日本一区二区免费| 久久婷婷国产剧情内射白浆 | 久久狠狠爱亚洲综合影院| 伊人久久大香线焦综合四虎| 久久精品aⅴ无码中文字字幕不卡| 久久久久亚洲AV成人网人人软件| 久久99精品国产一区二区三区| 国内精品久久久久影院优| 色婷婷久久久SWAG精品| 九九热久久免费视频| 久久精品www人人爽人人| 久久久久99精品成人片直播| 久久综合给合久久国产免费| 日本久久久久亚洲中字幕| 久久亚洲精品无码AV红樱桃| 三上悠亚久久精品|