poj 2536 GopherII(二分图匹配)】的更多相关文章

题意:每头奶牛都只愿意在她们喜欢的那些牛栏中产奶,告诉每头奶牛愿意产奶的牛棚编号,求出最多能分配到的牛栏的数量. 分析:直接二分图匹配: #include<stdio.h> #include<memory.h> #define MAX 202 bool flag,visit[MAX]; //记录V2中的某个点是否被搜索过 int match[MAX]; //记录与V2中的点匹配的点的编号 int cow, stall; //二分图中左边.右边集合中顶点的数目 int head[MA…
题意 在一个N*M的矩形里,用1*2的骨牌去覆盖该矩形,每个骨牌只能覆盖相邻的两个格子,问是否能把每个格子都盖住.PS:有K个孔不用覆盖. 思路 容易发现,棋盘上坐标和为奇数的点只会和坐标和为偶数的点相邻,所以这是个二分图.而每两个格子对应一个骨牌,并且一个格子只能被一个骨牌覆盖,这样就联想到了二分图匹配.把图中能覆盖的格子从1 依次标号 若格子数为奇数 答案是NO 否则,把相邻的两个标号能连成一条边,求无向图的二分匹配数,当匹配数 == 格子数时,就能覆盖完. 代码 #include #inc…
Description The gopher family, having averted the canine threat, must face a new predator. The are n gophers and m gopher holes, each at distinct (x, y) coordinates. A hawk arrives and if a gopher does not reach a hole in s seconds it is vulnerable t…
以行列为点建图,每个点(x,y) 对应一条边连接x,y.二分图的最小点覆盖=最大匹配 //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostream> #include<sstream>…
题目链接:http://poj.org/problem?id=1274 The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23088   Accepted: 10285 Description Farmer John completed his new barn just last week, complete with all the latest milking technology.…
题意:见挑战230页 #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <map> #include <algorithm> #include <set> using…
每个门每个时间只能出一个人,那就把每个门拆成多个,对应每个时间. 不断增加时间,然后增广,直到最大匹配. //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostream> #include<…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1882 http://poj.org/problem?id=2536 题目大意: 有n之地鼠和m个地洞,他们需要在s秒内以v秒的速度跑进洞中,否则会被鹰抓走.给定每个地鼠和洞的坐标,每个洞最多容纳一只地鼠,问最小有危险的地鼠个数. 思路: 跑回学校了~来A几题. 几个月前看的题不会做T T,现在好简单... 本题可以转化为二分图匹配.如果地鼠到洞的时间小于s,那么久建一条边…
POJ 2195 Going Home (带权二分图匹配) Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a…
POJ 2289 Jamie's Contact Groups / UVA 1345 Jamie's Contact Groups / ZOJ 2399 Jamie's Contact Groups / HDU 1699 Jamie's Contact Groups / SCU 1996 Jamie's Contact Groups (二分,二分图匹配) Description Jamie is a very popular girl and has quite a lot of friends…