poj 2536 二分图 最大匹配
来源:互联网 发布:steinberg ur22 mac 编辑:程序博客网 时间:2024/06/06 02:38
题意:老鹰抓地鼠,跑不到洞里的就要被吃掉,求合理安排最少被吃掉
解法:左集合是地鼠,右集合是洞,在规定的时间可以到达洞里的进行连线。
/*---------------------------------- Love is more than a word. It says so much. When I see these four letters, I almost feel your touch. This is only happened since I fell in love with you. Why this word does this, I haven't got a clue. To My Goddess CY----------------------------------*/#include<iostream>#include<cstring>#include<algorithm>#include<cstdlib>#include<vector>#include<cmath>#include<stdlib.h>#include<iomanip>#include<list>#include<deque>#include<map>#include <stdio.h>#include <queue>#define maxn 500+5#define ull unsigned long long #define ll long long#define reP(i,n) for(i=1;i<=n;i++) #define REP(i,a,b) for(i=a;i<=b;i++) #define rep(i,n) for(i=0;i<n;i++)#define cle(a) memset(a,0,sizeof(a)) #define clehead(a) rep(i,maxn)a[i]=-1/* The time of story : ** while(1) { once upon a time, there was a mountain, on top of which there was a temple, in which there was an old monk and a little monk. Old monk was telling stories inside the temple. What was he talking about? ** } ÎûÎû (*^__^*)*/#define sci(a) scanf("%d",&a) #define scd(a) scanf("%lf",&a) #define pri(a) printf("%d",a) #define prie(a) printf("%d\n",a) #define prd(a) printf("%lf",a) #define prde(a) printf("%lf\n",a) #define pre printf("\n")#define LL(x) x<<1 #define RR(x) x<<|1#define pb push_back#define mod 90001#define PI 3.141592657const ull INF = 1LL << 61;const int inf = int(1e5)+10;const double eps=1e-5;using namespace std;struct node{ double x,y;};node start[maxn];node end[maxn];bool cmp(int a,int b){ return a>b;}bool bmap[maxn][maxn];bool bmark[10000];int nx,ny;int cx[10000];int cy[10000];int dir[4][2]={0,-1,-1,0,1,0,0,1};int findpath(int u){ int i,j,k; rep(i,ny){ if(bmap[u][i]&&!bmark[i]){ bmark[i]=1; if(cy[i]==-1||findpath(cy[i])) { cy[i]=u; cx[u]=i; return 1; } } } return 0;}int maxmatch(){ int i,j,k; int res(0); rep(i,nx)cx[i]=-1; rep(j,ny)cy[j]=-1; rep(i,nx){ if(cx[i]==-1){ rep(j,ny)bmark[j]=0; res+=findpath(i); } } return res;}double len;bool getbool(node a,node b){ double temp=(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); return temp<=len*len;}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int i,j,k; while(cin>>nx>>ny) { double s,v; cin>>s>>v; len=s*v; rep(i,nx) { cin>>start[i].x>>start[i].y; } rep(i,ny) { cin>>end[i].x>>end[i].y; } cle(bmap); rep(i,nx) { rep(j,ny) { if(getbool(start[i],end[j])) { // cout<<i<<":"<<j<<endl; bmap[i][j]=true; } } } cout<<nx-maxmatch()<<endl; } return 0;}
0 0
- poj 2536 二分图 最大匹配
- 【二分图+最大匹配】北大 poj 2536 Gopher II
- POJ 2536 Gopher II(二分图最大匹配)
- POJ 2536 Gopher II(二分图最大匹配)
- POJ 2536 Gopher II(二分图的最大匹配)
- poj 2536 Gopher II 二分图最大匹配
- POJ 2536 Gopher II (二分图求最大匹配)
- POJ - 2536 Gopher II 二分图 最大匹配
- POJ 2536 Gopher II (二分图最大匹配)
- POJ 2536 Gopher II(二分图最大匹配)
- poj 2536 Gopher II(二分图最大匹配,构图)
- POJ 2536 Gopher II(二分图最大匹配)
- POJ 2536 Gopher II(二分图最大匹配)
- POJ-2536 Gopher II(二分图最大匹配)
- POJ 1274 二分图最大匹配
- POJ 1469 二分图最大匹配
- POJ 2239 二分图最大匹配
- Asteroids(poj 3041,二分图最大匹配)
- Linux 常用 性能 检测 命令 解释
- Android应用程序开机开机启动
- java设计模式之——策略模式
- Eclipse快捷键 10个最有用的快捷键
- hdu2795-Billboard
- poj 2536 二分图 最大匹配
- jquery 弹出框 使用popup
- 在vs2010上用OpenCv2.4.4显示图片
- servle
- ThinkPHP点击菜单后页面无法出来
- 解决jsp页面传值乱码问题
- android中怎么给TextView的部分字段加下划线并设置监听事件
- Error: An attempt was made to reference a token that does not exist.
- Android程序中Acticity间传递数据