青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

出處:???? http://acm.hnu.cn:8080/online/?action=problem&type=show&id=11203&courseid=0




Sudoku
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 10, Accepted users: 10
Problem 11203 : Special judge
Problem description
A Sudoku puzzle, once solved, is a 9x9 grid of digits organized as a 3x3 grid of smaller 3x3 units. Each of the nine rows must contain every positive digits exactly once, as do each column and also each 3x3 unit. The puzzle is to start from a partially filled 9x9 grid and to fill in the remaining cells using only logic. The puzzle maker usually makes sure that the solution will be unique and that it can be reached using deduction only, without guessing.

This number placing game is gaining popularity in the west, and every second newspaper publishes weekly instances of the puzzle. Somewhere at the head of one such newspaper, someone decided that buying individual instances from a puzzle maker would be too expansive, and instead decided to steal puzzles from other newspapers and also to print randomly generated Sudoku-like grids.

One week later, his assistant gets stuck with the job of printing the solution to the Sudoku puzzles his boss previously published. Unfortunately, his boss doesn’t have those solutions, the randomly generated problems don’t have any solution, and he doesn’t even remember which is which. In despair, the assistant calls for your help.



Input
The first line of the input will contain the number of test cases. Each test case will consist of a 9 by 9 grid of characters, where each character will either be ‘?’ or a digit between 1 and 9 inclusively.

Output
For each test case, you must print back the grid to the standard input, replacing each question mark with an appropriate digit to solve the Sudoku. If a test case does not allow any solution, output ”impossible” instead of a completed grid. If a test case do allow a solution, you can assume that the solution will be unique, and that theoretically it could be reached without guessing.

Test cases are separated by “---” both in the input and in the output.

Sample Input
3
            ??4??9??8
            ?3??5??1?
            7??4??2??
            3??8??1??
            ?5?????9?
            ??6??1??2
            ??8??3??1
            ?2??4??5?
            6??1??7??
            ---
            ??4??9??8
            ?3??5??1?
            7??4??2??
            3??8??1??
            ?5?????9?
            ??6??1??2
            ??8??3??1
            62??4??5?
            6??1??7??
            ---
            3?1????76
            7??9?????
            2?5?3????
            ?????64?1
            ???2?1???
            1?25?????
            ????8?9?3
            ?????9??4
            51????7?8
            
Sample Output
264319578
            839257416
            715486239
            372894165
            451632897
            986571342
            548763921
            127948653
            693125784
            ---
            impossible
            ---
            391452876
            764918532
            285637149
            953876421
            678241395
            142593687
            426785913
            837169254
            519324768
            






??1 #include? < iostream >
??2
??3 using ? namespace ?std;
??4
??5 bool ?x[ 9 ][ 10 ];
??6 bool ?y[ 9 ][ 10 ];
??7 bool ?z[ 9 ][ 10 ];
??8 int ??result[ 9 ][ 9 ];
??9 int ??num = ? 0 ;
?10
?11
?12 int ?GetID(? int ?x,? int ?y?)
?13 {
?14 ???? if ?(?x < ? 3 ? && ?y < ? 3 ?)
?15 ???? return ? 0 ;
?16 ???? else ? if ?(?x < ? 3 ? && ?y >= ? 3 ? && ?y < ? 6 ?)
?17 ???? return ? 1 ;
?18 ???? else ? if ?(?x < ? 3 ? && ?y >= ? 6 ? && ?y < ? 9 ?)
?19 ???? return ? 2 ;
?20 ???? else ? if ?(?x >= ? 3 ? && ?x < ? 6 ? && ?y < ? 3 ?)
?21 ???? return ? 3 ;
?22 ???? else ? if ?(?x >= ? 3 ? && ?x < ? 6 ? && ?y >= ? 3 ? && ?y < ? 6 ?)
?23 ???? return ? 4 ;
?24 ???? else ? if ?(?x >= ? 3 ? && ?x < ? 6 ? && ?y >= ? 6 ? && ?y < ? 9 ?)
?25 ???? return ? 5 ;
?26 ???? else ? if ?(?x >= ? 6 ? && ?x < ? 9 ? && ?y < ? 3 ?)
?27 ???? return ? 6 ;
?28 ???? else ? if ?(?x >= ? 6 ? && ?x < ? 9 ? && ?y >= ? 3 ? && ?y < ? 6 ?)
?29 ???? return ? 7 ;
?30 ???? else ? if ?(?x >= ? 6 ? && ?x < ? 9 ? && ?y >= ? 6 ? && ?y < ? 9 ?)
?31 ???? return ? 8 ;
?32 }

?33
?34
?35 void ?Print()
?36 {
?37 ???? for ?(? int ?i = ? 0 ;?i < ? 9 ;? ++ i?)
?38 ???? {
?39 ???????? for ?(? int ?j = ? 0 ;?j < ? 9 ;? ++ j?)
?40 ?????????????printf( " %d " ,result[i][j]?);
?41 ????????
?42 ???????? if ?(?i < ? 8 ?)?printf( " \n " );
?43 ????}

?44 }

?45
?46
?47 bool ?GetXY(? int & ?xx,? int & ?yy?)
?48 {
?49 ???? for ?(? int ?i = ? 0 ;?i < ? 9 ;?i ++ ?)
?50 ???? {
?51 ???????? for ?(? int ?j = ? 0 ;?j < ? 9 ;?j ++ ?)
?52 ???????? if ?(?result[i][j] == ? 0 ?)
?53 ???????? {
?54 ????????????xx = ?i;
?55 ????????????yy = ?j;
?56 ????????????
?57 ???????????? return ? true ;
?58 ????????}

?59 ????}

?60 ????
?61 ???? return ? false ;????
?62 }

?63
?64
?65 void ?Try(? int ?xx,? int ?yy?)
?66 {
?67 ???? for ?(? int ?i = ? 1 ;?i <= ? 9 ;? ++ i?)
?68 ???? {
?69 ???????? if ?(? ! x[xx][i]? && ? ! y[yy][i]? && ? ! z[?GetID(xx,yy)?][i]?)
?70 ???????? {
?71 ???????????? int ?a,?b;
?72 ????????????
?73 ????????????result[xx][yy] = ?i;
?74 ????????????
?75 ????????????x[xx][i] = ? true ;
?76 ????????????y[yy][i] = ? true ;
?77 ????????????z[?GetID(xx,yy)?][i] = ? true ;
?78 ????????????
?79 ???????????? if ?(? ! GetXY(?a,?b?)?)
?80 ???????????? {
?81 ????????????????Print();
?82 ????????????????num = ? 1 ;
?83 ???????????????? return ;
?84 ????????????}

?85 ????????????
?86 ????????????Try(?a,?b?);?
?87 ????????????result[xx][yy] = ? 0 ;
?88 ????????????????
?89 ????????????x[xx][i] = ? false ;
?90 ????????????y[yy][i] = ? false ;
?91 ????????????z[?GetID(xx,yy)?][i] = ? false ;
?92 ????????}

?93 ????}

?94 }

?95
?96
?97
?98 int ?main()
?99 {
100 ???? int ?n;
101 ????scanf( " %d " , & n);
102 ???? char ?aaa[ 10 ];
103 ????
104 ???? for ?(? int ?mm = ? 0 ;?mm < ?n;?mm ++ ?)
105 ???? {
106 ???????? char ?graph[ 9 ][ 10 ];
107 ????????num = ? 0 ;
108 ????????
109 ????????memset(?x,? false ,? sizeof (x)?);
110 ????????memset(?y,? false ,? sizeof (y)?);
111 ????????memset(?z,? false ,? sizeof (z)?);
112 ????????memset(?result,? 0 ,? sizeof (?result?)?);
113 ????????
114 ???????? for ?(? int ?i = ? 0 ;?i < ? 9 ;? ++ i?)
115 ?????????????scanf( " %s " ,?graph[i]?);
116 ?????????????
117 ???????? for ?(? int ?i = ? 0 ;?i < ? 9 ;? ++ i?)
118 ???????? {
119 ???????????? for ?(? int ?j = ? 0 ;?j < ? 9 ;? ++ j?)
120 ???????????? if ?(?graph[i][j] != ? ' ? ' ?)
121 ???????????? {
122 ???????????????? int ?t = ?graph[i][j] - ? ' 0 ' ;
123 ????????????????result[i][j] = ?t;
124 ????????????????
125 ????????????????x[i][t] = ? true ;
126 ????????????????y[j][t] = ? true ;
127 ????????????????z[?GetID(?i,?j?)?][t] = ? true ;
128 ????????????}

129 ????????}

130 ????????
131 ???????? int ?x,?y;
132 ????????
133 ????????GetXY(?x,?y?);
134 ????????Try(?x,?y?);
135 ?????????????
136 ???????? if ?(?mm < ?n - ? 1 ?)
137 ???????? {
138 ?????????????printf( " \n---\n " );
139 ?????????????scanf( " %s " ,aaa);
140 ????????}
????
141 ????????
142 ???????? if ?(?num == ? 0 ?)
143 ?????????????printf( " impossible " );
144 ????}

145 ????
146 ???? return ? 0 ;
147 }

148 ????????????????
149
posted on 2008-08-19 08:14 Darren 閱讀(336) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            精品动漫一区| 9久re热视频在线精品| 国产精品一二一区| 牛牛影视久久网| 欧美精品尤物在线| 亚洲免费黄色| 亚洲欧洲在线播放| 精品99一区二区| 亚洲六月丁香色婷婷综合久久| 久久av一区二区三区漫画| 国产精品入口尤物| 日韩午夜视频在线观看| 妖精成人www高清在线观看| 亚洲黄色影院| 性伦欧美刺激片在线观看| 麻豆精品传媒视频| 欧美日韩综合在线| 久久精品视频一| 在线一区二区三区四区| 亚洲尤物视频网| 免费的成人av| 国产精品日韩一区二区| 国产欧美日韩在线视频| 亚洲国产成人高清精品| 亚洲欧美精品在线| 欧美交受高潮1| 国产精品久久久久999| 国产日产高清欧美一区二区三区| 亚洲欧美日韩另类| 欧美国产日韩视频| 久久精品91久久香蕉加勒比| 欧美精品v国产精品v日韩精品 | 久久久久国产精品厨房| 另类欧美日韩国产在线| 亚洲欧美日韩国产中文在线| 亚洲欧美色婷婷| 欧美婷婷在线| 亚洲影院在线观看| 老司机aⅴ在线精品导航| 国产精品人人做人人爽| 宅男在线国产精品| 亚洲亚洲精品三区日韩精品在线视频 | 久久综合给合久久狠狠色| 国产精品福利在线观看网址| 韩国在线一区| 久久亚洲精品一区二区| 午夜免费日韩视频| 国产亚洲欧美一区二区| 欧美一区二区日韩| 可以免费看不卡的av网站| 亚洲激情视频在线播放| 久久欧美肥婆一二区| 老司机免费视频一区二区| 久久久久久久性| 亚洲伊人伊色伊影伊综合网| 欧美在线亚洲一区| 亚洲午夜久久久久久久久电影院 | 亚洲精品久久久久久久久久久| 韩国一区二区在线观看| 欧美成人一区二区| 国产精品一区二区三区四区五区| 亚洲第一区在线观看| 日韩一级黄色片| 欧美一区二区三区在线观看视频| 亚洲激情图片小说视频| 在线观看中文字幕亚洲| 国产精品久久久久久亚洲调教| 欧美久久婷婷综合色| 国产精品综合色区在线观看| 亚洲乱码一区二区| 性18欧美另类| 欧美色图天堂网| 亚洲午夜精品一区二区三区他趣| 欧美电影在线观看完整版| 久久xxxx| 欧美日本精品一区二区三区| 亚洲国产婷婷香蕉久久久久久99 | 激情成人综合网| 久久久久久一区二区| 欧美性做爰毛片| 欧美呦呦网站| 一个色综合av| 久久精品综合| 亚洲欧美日韩一区| 欧美国产先锋| 亚洲欧洲在线免费| 在线免费观看日韩欧美| 欧美一区二区三区免费观看视频 | 国产精品久久久久久久免费软件| 国产精品欧美久久| 久久成年人视频| 欧美日韩一区二区国产| 欧美成年网站| 亚洲免费av网站| 欧美体内she精视频在线观看| 91久久在线观看| 欧美视频在线观看一区二区| 国产一区自拍视频| 欧美日本三区| 久久九九热免费视频| 亚洲国产精品尤物yw在线观看| 久久嫩草精品久久久精品| 亚洲精品一区二区三区四区高清 | 在线一区二区三区四区五区| 国产日韩欧美在线观看| 亚洲欧美一级二级三级| 久久成人精品无人区| 国产性天天综合网| 久久精品中文字幕免费mv| 欧美激情第六页| 久久国产精品亚洲77777| 亚洲精品一二三| 在线观看国产一区二区| 精品成人在线视频| 经典三级久久| 一区二区欧美激情| 国产午夜一区二区三区| 欧美日韩精品一区| 久久爱www| 亚洲欧美精品suv| 亚洲无限av看| 亚洲激情成人在线| 亚洲肉体裸体xxxx137| 一本到高清视频免费精品| 亚洲精品黄色| 久久大逼视频| 欧美一区二区三区四区视频| 亚洲精选在线| 亚洲精品综合久久中文字幕| 麻豆成人精品| 欧美 日韩 国产一区二区在线视频| 欧美电影美腿模特1979在线看| 西瓜成人精品人成网站| 在线欧美日韩国产| 亚洲福利专区| 久久国产一区二区| 欧美日韩国产色视频| 黄色工厂这里只有精品| 亚洲免费激情| 亚洲精品在线免费观看视频| 最新国产成人在线观看| 激情六月综合| 一区二区高清在线观看| 久久激情视频| 亚洲精品在线二区| 欧美精品日韩一区| 国产日韩欧美自拍| 亚洲一区高清| 久久国产欧美日韩精品| 免播放器亚洲一区| 一区二区精品| 久久成年人视频| 国产一区91| 午夜亚洲影视| 一区二区三区 在线观看视| 欧美激情中文字幕乱码免费| 亚洲精品一二| 亚洲国内高清视频| 久久亚洲捆绑美女| 在线日本欧美| 另类图片综合电影| 久久先锋影音av| 亚洲日韩欧美一区二区在线| 免费不卡视频| 国产区精品视频| 亚洲午夜电影网| 99精品免费网| 国产精品99一区二区| 欧美一区二区三区在线视频| 亚洲一区免费网站| 精品不卡一区| 欧美一区二区三区四区夜夜大片| 亚洲巨乳在线| 欧美精品在线一区二区| 在线观看日韩av先锋影音电影院| 国产精品一区二区久激情瑜伽| 久久婷婷色综合| 精品成人一区二区三区| 久久嫩草精品久久久精品| 国产偷自视频区视频一区二区| 亚洲天堂偷拍| 欧美精品一区在线| 香蕉av福利精品导航| 亚洲永久免费视频| 国自产拍偷拍福利精品免费一| 欧美日韩国产在线一区| 国产精品99久久久久久有的能看| 亚洲电影免费观看高清完整版在线 | 狠狠做深爱婷婷久久综合一区| 国产精品美女主播在线观看纯欲| 久久最新视频| 亚洲国产精品女人久久久| 欧美激情一区二区在线 | 国户精品久久久久久久久久久不卡 | 伊人久久男人天堂| 亚洲欧美久久久| 久久精品论坛| 国产精品日本| 日韩午夜在线播放| 激情久久婷婷|