题意:

给出N个点,M个边构成图。每选取一个点都可以覆盖其相邻点,问要覆盖所有点最少选几个点

思路:
每个点都作为一个点集,进行爆搜覆盖,舞蹈链模板题。

代码:

#include <bits/stdc++.h>using namespace std;const int maxn=60;
int L[maxn*maxn],R[maxn*maxn],U[maxn*maxn],D[maxn*maxn];
int C[maxn*maxn],H[maxn],cnt[maxn],vis[maxn];
int n,m,id,fans;
vector<int>G[maxn];
void init(){for(int i=0;i<=n;i++){G[i].clear();G[i].push_back(i);cnt[i]=0;U[i]=D[i]=i;L[i+1]=i;R[i]=i+1;}R[n]=0;id=n+1;memset(H,-1,sizeof(H));
}
void Link(int r,int c){cnt[c]++;C[id]=c;U[id]=U[c];D[U[c]]=id;D[id]=c;U[c]=id;if(H[r]==-1) H[r]=L[id]=R[id]=id;else{L[id]=L[H[r]];R[L[H[r]]]=id;R[id]=H[r];L[H[r]]=id;}id++;
}
void Remove(int Size){for(int j=D[Size];j!=Size;j=D[j])L[R[j]]=L[j],R[L[j]]=R[j];
}
void Resume(int Size){for(int j=D[Size];j!=Size;j=D[j])L[R[j]]=R[L[j]]=j;
}
int h(){int sum=0;memset(vis,0,sizeof(vis));for(int i=R[0];i;i=R[i]){if(vis[i]) continue;sum++;for(int j=D[i];j!=i;j=D[j]){for(int k=R[j];k!=j;k=R[k])vis[C[k]]=1;}}return sum;
}
void Dance(int k){int mm=maxn,pos;if(k+h()>=fans)return;if(!R[0]){if(k<fans)fans=k;return;}for(int i=R[0];i;i=R[i])if(mm>cnt[i]){mm=cnt[i];pos=i;}for(int i=D[pos];i!=pos;i=D[i]){Remove(i);for(int j=R[i];j!=i;j=R[j])Remove(j);Dance(k+1);for(int j=R[i];j!=i;j=R[j])Resume(j);Resume(i);}
}
int main(){int u,v;while(scanf("%d%d",&n,&m)!=-1){init();for(int i=0;i<m;i++){scanf("%d%d",&u,&v);G[u].push_back(v);G[v].push_back(u);}for(int i=1;i<=n;i++){int len=G[i].size();for(int j=0;j<len;j++){int t=G[i][j];Link(i,t);}}fans=n;Dance(0);printf("%d\n",fans);}return 0;
}
sevenzero liked Warcraft very much, but he haven't practiced it for several years after being addicted to algorithms. Now, though he is playing with computer, he nearly losed and only his hero Pit Lord left. sevenzero is angry, he decided to cheat to turn defeat into victory. So he entered "whosyourdaddy", that let Pit Lord kill any hostile unit he damages immediately. As all Warcrafters know, Pit Lord masters a skill called Cleaving Attack and he can damage neighbour units of the unit he attacks. Pit Lord can choice a position to attack to avoid killing partial neighbour units sevenzero don't want to kill. Because sevenzero wants to win as soon as possible, he needs to know the minimum attack times to eliminate all the enemys.

Input

There are several cases. For each case, first line contains two integer N (2 ≤ N ≤ 55) and M (0 ≤ M ≤ N*N),and N is the number of hostile units. Hostile units are numbered from 1 to N. For the subsequent M lines, each line contains two integers A and B, that means A and B are neighbor. Each unit has no more than 4 neighbor units. The input is terminated by EOF.

Output

One line shows the minimum attack times for each case.

Sample Input

5 4
1 2
1 3
2 4
4 5
6 4
1 2
1 3
1 4
4 5

Sample Output

2
3

HDU 3498 whosyourdaddy (可重复覆盖舞蹈链)相关推荐

  1. hdu - 3498 - whosyourdaddy(重复覆盖DLX)

    题意:N(2 ≤ N ≤ 55)个点,M(0 ≤ M ≤ N*N)条无向边,删除一个点会把与其相邻的点一起删掉,问最少删几次可以删掉所有点. 题目链接:http://acm.hdu.edu.cn/sh ...

  2. HDU 3498 whosyourdaddy DLX重复覆盖

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=3498 题意: 有 n n个敌人,其中有mm对敌人互为邻居,当你攻击杀死一个敌人时,同时会杀死它所有的邻居 ...

  3. HDU 3498 whosyourdaddy(DLX重复覆盖)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3498         n个点,m条无向边,删除一个点会把与其相邻的点一起删掉,问最少删几次可以删掉所有 ...

  4. hdu - 3498 - whosyourdaddy(反复覆盖DLX)

    题意:N(2 ≤ N ≤ 55)个点,M(0 ≤ M ≤ N*N)条无向边,删除一个点会把与其相邻的点一起删掉.问最少删几次能够删掉全部点. 题目链接:http://acm.hdu.edu.cn/sh ...

  5. hdu3498 whosyourdaddy--可重复覆盖舞蹈链

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=3498 题意:n个怪兽,m对怪兽的关系,表示怪兽a和b之间连线,当把一个怪兽杀死,和其直接相连的怪兽都死 ...

  6. HDU 3498 whosyourdaddy(Dancing_Links重复覆盖)

    题目地址 题意:给你n个城市,m条道路,每次摧毁一个城市会附带把与它直接连接的城市的摧毁,一个城市可以重复摧毁(如果不能重复就是精确覆盖了),问你最少摧毁多少个城市能把所有城市摧毁. 思路:我们可以构 ...

  7. [DLX重复覆盖] hdu 3498 whosyourdaddy

    题意: 给N个怪,M个关系. 每个关系代表a和b是邻居. 然后问每次攻击你可以攻击一个怪以及它的全部邻居 问最少需要几次攻击能把怪全部杀死. 思路: 怪为行和列,然后对面每个怪的邻居都是这个怪的列建图 ...

  8. hdu 3498 whosyourdaddy

    Dancing Links 重复覆盖问题~ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3498 这两天学习了Dancing Links  ,它主要 ...

  9. hdu 2295 Radar DLX 重复覆盖问题

    http://acm.hdu.edu.cn/showproblem.php?pid=229 题意: 一个国家有n个城市,m个雷达,我们同时操作的雷达数最多为k,给出城市与国家的坐标,求小于等于k的操作 ...

最新文章

  1. 一文看尽各种 NLP 任务
  2. 互联网直播云计算架构介绍
  3. 点量OTT TV 点播软件模式为何受海外华人运营者喜爱?
  4. irrlicht1.3中文支持
  5. Spring中的简单实现AOP小例子
  6. java 读取内存地址结构体_Java并发系列之volatile
  7. 流水线、精益生产、丰田生产方式和TOC的基本原则
  8. 组队APP功能点定点NABCD分析
  9. 职业生涯规划访谈记录关于计算机专业,计算机专业职业生涯规划书
  10. 你理解的智能家居就是智能家居么?
  11. iOS开发-dispatch_once相关
  12. 软件项目经理应具备的素质和条件_软件项目经理素质能力的必备要求
  13. 网站通过nginx设置黑/白名单IP限制、国家城市IP访问限制
  14. 11:ERNIE-VIL:KNOWLEDGE ENHANCED VISION-LANGUAGE REPRESENTATIONS THROUGH SCENE GRAPH
  15. text/plain
  16. gym101532 2017 JUST Programming Contest 4.0
  17. 【转载】什麼是超焦距(Hyperfocal Distance)?如何找出它的位置?
  18. ME909S-821 4G-LTE模块在Linux系统下拨号上网测试
  19. qfile超过下载文件容量_如何下载视频网站上的视频,这里有方法
  20. 光纤、光模块为什么成对的?

热门文章

  1. 量子隐形传态和超密编码
  2. 【附带配置疑问解决】Keil5配置ST-Link仿真器下载程序的方法
  3. 乔布斯是如何形象解释 OOP 的
  4. webSocket一对一 、一对多通信
  5. 基于51单片机的音乐盒设计
  6. 使用 TELNET 发送 SMTP 邮件详解
  7. //众神云集、群魔乱舞、以一抵百、砥砺前行//18640 扩号匹配问题
  8. 生产型企业中采购管理系统的优势有哪些?
  9. Scurity and Network-signature
  10. PTA 7-6 大笨钟