From 23dfdac7bb221980e11ca932fc7b98c8fc6335d0 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Fri, 21 Jul 2017 21:12:54 +0800 Subject: [PATCH] Create 1321_sshaohua.cpp From http://poj.org/showmessage?message_id=353467 --- POJ/1321_sshaohua.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 POJ/1321_sshaohua.cpp diff --git a/POJ/1321_sshaohua.cpp b/POJ/1321_sshaohua.cpp new file mode 100644 index 0000000..b96f154 --- /dev/null +++ b/POJ/1321_sshaohua.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include +#include +//notice the '#' can be placed. +using namespace std; +const int MAXN = 10; + +int n, m; +int ans = 0; +char my_map[MAXN][MAXN]; +bool vis_row[MAXN]; //vis_row[i], i row is visited. +bool vis_col[MAXN]; //vis_col[j], j col is visited. + +bool judge(int x, int y){ + if(x<0 || x>=n || y<0 || y>=n || my_map[x][y]!='#') return false; + if(vis_row[x] || vis_col[y]) return false; + return true; +} + +void DFS(int x, int y, int step){ + //int xx, yy; + if(step == m) {ans++; return;} + for(int i=x; i