hdu 1281 棋盘游戏
来源:互联网 发布:xampp mac 修改根目录 编辑:程序博客网 时间:2024/05/16 09:03
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1281
本题为简单最小点覆盖。只需先求出最小点覆盖然后枚举所有的点。
#include<stdio.h>#include<string.h>#define maxn 105bool map[maxn][maxn],vis[maxn];int n,m,k,mark[maxn],edge[maxn*maxn][2];bool dfs(int v){for(int i = 1; i <= m; i++){if(vis[i] || !map[i][v])continue;vis[i] = true;if(mark[i] == 0|| dfs(mark[i])){mark[i] = v;return true;}}return false;}int Hungarian(){//匈牙利算法求二分图的最大匹配int count = 0;memset(mark,0,sizeof(mark));for(int i = 1; i <= n; i++){memset(vis,false,sizeof(vis));if(dfs(i))count ++;}return count;}int main(){int i,sum,num = 1;while(scanf("%d%d%d",&n,&m,&k) != EOF){memset(map,false,sizeof(map));for(i = 0; i < k; i++){scanf("%d%d",&edge[i][0],&edge[i][1]);map[edge[i][0]][edge[i][1]] = true;}int max ;//求最小点覆盖max = Hungarian();//枚举所有的点。for(i = sum = 0; i < k; i++){map[edge[i][0]][edge[i][1]] = false;if(max > Hungarian())sum ++;map[edge[i][0]][edge[i][1]] = true;}printf("Board %d have %d important blanks for %d chessmen.\n",num++,sum,max);}return 0;}
- hdu 1281棋盘游戏
- hdu 1281 棋盘游戏
- HDU 1281 棋盘游戏
- hdu 1281 棋盘游戏
- hdu 1281 棋盘游戏
- HDU 1281 棋盘游戏
- hdu 1281 棋盘游戏
- HDU 1281 棋盘游戏
- HDU 1281 棋盘游戏
- hdu 1281 棋盘游戏
- hdu 1281 棋盘游戏
- hdu 1281 棋盘游戏
- 【HDU】 1281 棋盘游戏
- HDU 1281:棋盘游戏
- HDU 1281 棋盘游戏
- HDU 1281 棋盘游戏
- HDU - 1281 棋盘游戏
- hdu 1281 棋盘游戏
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- 论MMORPG游戏服务器架构
- 图像特征检测(Image Feature Detection)
- Goldbach's Conjecture map+素数表
- 小企业如何消除“成长的烦恼”呢?
- hdu 1281 棋盘游戏
- 我为什么没有加入苹果的iOS APP移动大军?[最近更新:2015-02-03]
- 常见设计模式之【外观模式】
- 找回本机MySQL密码的方法
- Lync Server 2010和Exchange Server 2010 OWA(IM)集成异常
- 33. 实现桌球的反弹
- Oracle Permanent Space Usage Related Queries
- 模板匹配(Match Template)
- Untiy 网络通信。。三合一。。。。