HDU 1151Air Raid 最小路径覆盖=n-最大匹配量 (第二道二分匹配)
2012-07-30 03:44
399 查看
#include<iostream> #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<algorithm> using namespace std; int map[125][125],ve[125],vs[125]; int s,e; int getpath(int u) { int i; for(i=1;i<=s;i++) { if(!map[u][i] || ve[i]) continue; ve[i]=1; if(!vs[i] || getpath(vs[i])) { vs[i]=u; return 1; } } return 0; } int main() { // freopen("in.txt","r",stdin); int i,a,b,t; scanf("%d",&t); while(t--) { memset(map,0,sizeof(map)); memset(vs,0,sizeof(vs)); scanf("%d%d",&s,&e); for(i=0;i<e;i++) { scanf("%d%d",&a,&b); map[a][b]=1; } int ans=0; for(i=1;i<=s;i++) { memset(ve,0,sizeof(ve)); ans+=getpath(i); } printf("%d\n",s-ans); } return 0; }
[/code]
相关文章推荐
- HDU 1151Air Raid 最小路径覆盖=n-最大匹配量 (第二道二分匹配)
- HDU 1151Air Raid 最小路径覆盖=n-最大匹配量 (第二道二分匹配)
- HDU 4160 最小路径覆盖 = 顶点数 - 最大匹配数 二分匹配
- poj 2594 Treasure Exploration(最小路径覆盖/二分最大匹配)
- hdu 1054 Strategic Game(模板) 最大二分匹配,最小点覆盖 匈牙利算法
- hdu 4160 Dolls【最小路径覆盖----二分匹配】
- POJ 3020 最小路径覆盖 = 顶点数-最大匹配数 二分匹配
- 【POJ3020】【总数-最大二分匹配】【最小路径覆盖和点覆盖的区别是 路径的话要所有点覆盖了】
- hdu1151 poj1422 最小路径覆盖.最大二分匹配
- HDU-1150(求最小覆盖顶点数=二分最大匹配数)
- hdu 1151 Air Raid 最小路径覆盖(最大匹配)
- UVa live3126Taxi Cab Scheme(二分最大匹配之最小路径覆盖)
- HDU 3861--The King’s Problem【scc缩点构图 && 二分匹配求最小路径覆盖】
- poj3020 匈牙利算法+公式:二分无向图的最小路径覆盖 = 顶点数 - 最大二分匹配数 / 2
- hdu 3861 强连通分量缩点+二分匹配求最小路径覆盖
- hdu 1151 Air Raid (二分匹配,最小路径覆盖)
- HDU 1498 50 years, 50 colors(二分最大匹配之最小点覆盖)
- HDU-1151(求最小覆盖路径数_二分匹配)
- HDU 4160 Dolls (最小路径覆盖=顶点数-最大匹配数)
- HDU 3861--The King’s Problem【scc缩点构图 && 二分匹配求最小路径覆盖】