-
Notifications
You must be signed in to change notification settings - Fork 1
/
方格填数.cpp
46 lines (39 loc) · 1.02 KB
/
方格填数.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
#include<vector>
using namespace std;
vector<char> path(10, -1);
int flag[10];
void dfs(int step) {
if(step == 11) {
// for(int i=0; i<path.size(); i++)
// cout << path[i] << " ";
// cout << endl;
return;
}
for(int i=0; i<10; i++) {
if(flag[i] == 0) {
int can = true;
if(step == 2) {
if(path[6]+1==2 || path[6]-1==2)
can = false;
} else if(step == 3) {
if(path[4]+1==3 || path[4]-1==3 || path[7]+1==3 || path[7]-1==3)
can = false;
} else if(step == 4) {
} else if(step == 5 || step == 6) {
} else if(step == 7) {
} else if(step == 8) {
} else if(step == 9) {
} else if(step == 10) {
}
flag[i] = 1;
path.push_back(vv[i]);
dfs(step+1);
path.pop_back();
flag[i] = 0;
}
}
}
int main() {
dfs(0);
}