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

出處:???? 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>
            av72成人在线| 亚洲一区二区三区乱码aⅴ| 久久久久久久国产| 亚洲欧美日韩在线播放| 亚洲免费在线观看视频| 亚洲最新视频在线| 在线亚洲精品| 精品91免费| 久久精品国产免费看久久精品| 在线观看视频一区二区| 黄色成人在线| 亚洲剧情一区二区| 亚洲午夜精品| 久久亚洲春色中文字幕| 欧美成人日韩| 一区二区高清视频在线观看| 亚洲在线视频| 久久久久久一区二区| 欧美国产先锋| 国产精品成人一区二区| 国产综合色一区二区三区| 亚洲区欧美区| 午夜精品电影| 亚洲第一毛片| 亚洲欧美国产三级| 久久久久中文| 国产精品入口福利| 亚洲黄一区二区三区| 亚洲欧美日韩网| 欧美激情精品久久久久久变态| 一本色道久久88亚洲综合88| 久久精品国产精品| 欧美午夜精品一区| 亚洲第一在线| 久久成人av少妇免费| 亚洲欧洲在线一区| 久久福利视频导航| 国产精品久久国产精品99gif| 亚洲狠狠丁香婷婷综合久久久| 免费观看久久久4p| 国产欧美日韩麻豆91| 亚洲免费观看| 你懂的国产精品| 欧美一级专区免费大片| 欧美性淫爽ww久久久久无| 亚洲国产合集| 欧美一区二区精品在线| 亚洲乱码国产乱码精品精可以看 | 亚洲国产精品成人精品 | 玖玖精品视频| 国内精品伊人久久久久av影院 | 在线观看国产一区二区| 久久国产日本精品| 亚洲欧美在线一区| 国产精品日产欧美久久久久| 一区二区三区欧美日韩| 亚洲精品久久久久久久久久久久久| 麻豆精品在线视频| 中文在线不卡| 午夜在线精品| 亚洲一区二区三区视频| 国产精品一区二区久久| 欧美一区二区三区四区在线| 亚洲一级特黄| 国产视频一区二区三区在线观看| 欧美在线黄色| 久久久久国产精品一区二区| 亚洲国产岛国毛片在线| 欧美gay视频| 免费看亚洲片| 亚洲视频专区在线| 亚洲欧美中文日韩v在线观看| 欧美国产在线视频| 在线性视频日韩欧美| 亚洲午夜高清视频| 国产亚洲观看| 欧美激情无毛| 国产精品乱人伦一区二区 | 国产精品自拍在线| 欧美一区二区三区的| 欧美一区二区三区在线| 亚洲国产精品成人综合| 亚洲精品欧美日韩专区| 欧美午夜无遮挡| 久热精品视频在线观看一区| 欧美精品久久一区二区| 欧美亚洲综合久久| 久久久久久久久久久成人| 亚洲人成毛片在线播放女女| 99av国产精品欲麻豆| 国产有码一区二区| 最近中文字幕mv在线一区二区三区四区 | 亚洲第一网站免费视频| 欧美日韩在线大尺度| 久久久久国产精品厨房| 欧美电影免费观看高清完整版| 亚洲尤物影院| 蜜臀99久久精品久久久久久软件| 在线亚洲免费| 久久一本综合频道| 欧美一区二区三区在线| 欧美精品久久久久久久久久| 久久亚洲二区| 国产精品美女www爽爽爽视频| 欧美成人一区在线| 国产欧美91| 日韩一级二级三级| 亚洲国产精品传媒在线观看 | 99精品欧美一区二区蜜桃免费| 亚洲综合国产| 亚洲美女黄色片| 午夜日本精品| 亚洲欧美日韩中文播放| 国产一区二区三区的电影| 91久久精品国产91性色tv| 国产一区二区三区网站| 一本一本久久| 亚洲精品一区中文| 欧美在线一二三四区| 午夜精品久久久久久久久久久久| 欧美福利在线| 牛牛国产精品| 一区国产精品| 欧美影院午夜播放| 欧美一区视频| 国产欧美日韩三级| 亚洲尤物在线| 久久国产精品久久久| 国产精品久久久久久久久久久久久| 亚洲大片在线| 亚洲黄一区二区| 蜜桃av综合| 欧美电影在线免费观看网站| 亚洲成色777777女色窝| 久久久久久久成人| 男人天堂欧美日韩| 亚洲黄色一区| 欧美精品成人| 夜夜嗨av一区二区三区网页 | 国产一区日韩二区欧美三区| 午夜精品免费| 久久精品国产在热久久| 国内成人在线| 久久全国免费视频| 欧美成人精品在线| 亚洲人成亚洲人成在线观看图片| 美女视频黄 久久| 欧美激情一区二区三区成人| 亚洲经典三级| 欧美日韩久久久久久| 中日韩男男gay无套| 久久黄金**| 亚洲国产日韩欧美在线99| 欧美不卡一区| 亚洲美女在线一区| 欧美在线视频免费| 在线精品观看| 欧美午夜a级限制福利片| 亚洲欧美欧美一区二区三区| 久久最新视频| 在线综合亚洲欧美在线视频| 国产精品一二一区| 久久激情中文| 亚洲日本国产| 久久国产欧美精品| 亚洲韩国精品一区| 欧美色大人视频| 久久久久久久久久久久久9999| 亚洲精品少妇30p| 欧美在线观看一区二区三区| 在线观看欧美| 国产精品美女午夜av| 久久夜色精品国产欧美乱| 日韩视频一区二区在线观看 | 一区二区三区久久久| 久久久久久自在自线| 日韩一级黄色大片| 激情久久久久久| 欧美色播在线播放| 麻豆精品网站| 欧美电影在线观看| 亚洲午夜精品久久久久久浪潮| 裸体一区二区| 亚洲免费影视| 亚洲欧洲美洲综合色网| 国产美女精品人人做人人爽| 欧美高清免费| 久久尤物电影视频在线观看| 在线视频亚洲| 亚洲黄网站黄| 欧美成va人片在线观看| 欧美专区在线| 亚洲香蕉网站| 亚洲国内欧美| 亚洲一级网站| 亚洲伦理在线免费看| 久久综合久久美利坚合众国| 欧美一区二区视频在线观看2020| 一本不卡影院| 一区二区久久久久|