This commit is contained in:
Zengtudor 2024-08-23 23:14:35 +08:00
parent 06af1b4c52
commit ba9ec63d10
2 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,9 @@
17.5..8..
.52.1....
.....759.
.8...94.3
.197.4..8
7......15
4.1...6..
3...2..59
...96..3.

View File

@ -1,7 +1,104 @@
//NOT DONE
#include<bits/stdc++.h>
using namespace std;
#ifdef OI
#define DB(code){code}
#else
#define DB(code)
#endif
int m[10][10];
// bool check_h[10][10],check_l[10][10],check_yx[20][10],check_zx[20][10];
// bool check_all(int x,int y,int num){
// if(check_h[x][num]){
// return false;
// }
// if(check_l[y][num]){
// return false;
// }
// if(check_yx[x-y+8][num]){
// return false;
// }
// if(check_zx[])
// }
// bool check(int x,int y,int num);
bool check(int x,int y,int num);
void dfs(int x,int y){
if(x==9&&y==9){
for(int i=1;i<=9;i++){
for(int j=1;j<=9;j++){
cout<<m[i][j];
}
cout<<endl;
}
exit(0);
}
for(int i=1;i<=9;i++){
}
}
int main(){
for(int i=1;i<=9;i++){
char ch[15];
cin.getline(ch,10);
for(int j=1;j<=9;j++){
if(ch[j-1]=='.'){
m[i][j]=-1;
}else{
m[i][j]=ch[j-1]-'0';
}
}
}
DB(
for(int i=1;i<=9;i++){
for(int j=1;j<=9;j++){
cout<<m[i][j]<<" ";
}
cout<<endl;
}
)
}
// void dfs(int x,int y){
// }
bool check(int x,int y,int num){
for(int i=1;i<=9;i++){
if(m[i][y]==num){
return false;
}
}
for(int i=1;i<=9;i++){
if(m[x][i]==num){
return false;
}
}
for(int i=x+1,j=y+1;i<=9&&j<=9;i++,j++){
if(m[i][j]==num){
return false;
}
}
for(int i=x-1,j=y-1;i>=1&&j>=1;i--,j--){
if(m[i][j]==num){
return false;
}
}
return true;
}
/*
17.5..8..
.52.1....
.....759.
.8...94.3
.197.4..8
7......15
4.1...6..
3...2..59
...96..3.
*/