hdu4770Lights Against Dudely(二)

2014-11-24 02:07:59 · 作者: · 浏览: 4
We have carefully selected several similar problems for you: 4780 4779 4778 4777 4776
Statistic | Submit | Discuss | Note
题意:一幅地图里面有坚实的房间和虚弱的房间,你需要用灯来照亮虚弱的房间,
但是不能照到坚实的房间。有两种灯。问最小需要多少盏灯才能照亮全部的虚弱房间
刚开始还没什么想法。还一直在想要用到什么算法。
但是后来一看数据量,才15个虚弱的房间。。
直接枚举才2^15*15种可能,绝对不会超时的
然后就想到状态压缩,对于每个虚弱的房间都有两种可能。一种是放灯,一种是不放灯。
也就是要用以为,把每一种状态都考虑一遍,再更新最小值。
#include  
#include  
char map[205][205];  
int dir[][2] = {{-1,0},{0,1},{1,0},{0,-1}};  
struct node   
{  
    int x,y;  
}node[20];     //存地图中的‘.’的横纵坐标  
int min(int a,int b)  
{  
    return a