poj-1321 棋盘问题 DFS

        汉语题,不解释题意,该题关键是要找到一个枚举的方法,刚开始搜索的思路不是很好找。我也是参考了其他网友的思路,写了这个代码,不是很好解释,直接看把。

#include 
#include 
#include 
#include 
#include 
#include 
#define INF 0x3f3f3f3f

using namespace std;

int n,k,ans;
char map[20][20];
int vis[20];

void DFS(int x,int num)
{
    if(num==k)
    {
        ans++;
        return;
    }
    if(x>=n) return;
    for (int i=0;i


你可能感兴趣的:(POJ,DFS/BFS)