Treasure Exploration----有路径重叠的最小路径覆盖
来源:互联网 发布:js数组slice 编辑:程序博客网 时间:2024/06/02 09:08
题目:http://poj.org/problem?id=2594
注:用floyd,将i点与i可到达的点相连,再求最小路径覆盖即可。
源代码:
#include <stdio.h>#include <string.h>#define MAXN 505int map[MAXN][MAXN];int vx[MAXN],vy[MAXN],v[MAXN];int cas,nx,ny,n,m;int uu,vv;int dfs(int x){ v[x]=1; for(int y=1;y<=ny;y++) if(map[x][y]==1) { if(vy[y]==-1||(v[vy[y]]==0&&dfs(vy[y]))) { vx[x]=y; vy[y]=x; return 1; } } return 0;}int MaxMatch(){ int ans=0; for(int i=1;i<=nx;i++) vx[i]=-1; for(int i=1;i<=ny;i++) vy[i]=-1; for(int i=1;i<=nx;i++) { for(int j=1;j<=nx;j++) v[j]=0; if(dfs(i)) ans++; } return ans;}int main(){ //freopen("F:\\a.txt","r",stdin); while(1) { scanf("%d %d",&n,&m); if(!n&&!m) break; memset(map,0,sizeof(map)); for(int i=0;i<m;i++) { scanf("%d %d",&uu,&vv); map[uu][vv]=1; } nx=ny=n; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) if(map[i][j]&&map[j][k]) map[i][k]=1; printf("%d\n",n-MaxMatch()); } return 0;}
- Treasure Exploration----有路径重叠的最小路径覆盖
- 可重叠的最小路径覆盖 poj2594 Treasure Exploration
- HDU 2594 Treasure Exploration(有向图最小可重叠路径覆盖)
- (floyd+最小路径覆盖) Treasure Exploration (P2594)
- POJ2594-Treasure Exploration(最小路径覆盖变形)
- POJ 2594 Treasure Exploration 最小路径覆盖
- POJ2594 Treasure Exploration(最小路径覆盖)
- poj2594 Treasure Exploration【最小路径覆盖】
- POJ-2594-Treasure Exploration-(路径相交的最小路径覆盖+闭包传递)
- POJ 2594 Treasure Exploration-有向图最小路径覆盖&Floyd
- Treasure Exploration(POJ_2594) -有向图可重复点-最小路径覆盖
- POJ 2594 Treasure Exploration(传递闭包+最小路径覆盖)
- poj 2594 Treasure Exploration最小路径覆盖+传递闭包
- POJ 2594 Treasure Exploration(最小路径覆盖变形)
- POJ 题目2594 Treasure Exploration(最小路径覆盖)
- POJ2594 Treasure Exploration【二分图最小路径覆盖】【Floyd】
- poj 2594 Treasure Exploration 最小路径覆盖/最大匹配
- POJ 2594 — Treasure Exploration 最小路径覆盖
- magento 积分插件 J2T Reward Points + Referral program VA 下载
- 类似VM菜单的简单实现
- Magento 导入导出分类插件Category Import Export使用教程
- [泛型经典]Java5泛型的用法,T.class的获取和为擦拭法站台
- 正则验证身份证
- Treasure Exploration----有路径重叠的最小路径覆盖
- 推荐几个游戏
- Asp.net多语言处理(数据库,XML,资源文件等)
- Oracle APEX 使用htp和htf生成html源码(含css和javascript)和处理业务逻辑
- poj 1948 Triangular Pastures 二维背包
- erlang与游戏服务器……
- Java Web层框架比较—— 比较JSF、Spring MVC、Stripes、Struts 2、Tapestr和Wicket他们各自的优、缺点
- android面试题总结加强再加强版(一)
- C#解析XML的特点比较和总结