Jewelry Exhibition(最小点覆盖集)
Jewelry Exhibition
时间限制: 1 Sec 内存限制: 64 MB
提交: 3 解决: 3
[提交][状态][讨论版]
题目描述
Any room has a rectangle shape, so we describe it as an [0, N] × [0, M] rectangle in the plane. The objects we need to guard are represented as points inside that rectangle. Each sender is mounted on a wall and the corresponding receiver on the opposite wall in such a way that the generated strip is a rectangle of unit width and length either N or M. Since the new laser beam system is still not perfect, each sender-receiver pair can only be mounted to generate strips the corners of which have integer coordinates. An additional drawback is that the sender-receiver pairs can protect only
items inside the strips, but not those lying on their borders. Thus, the security agency arranged the exhibits in such a way that both coordinates of any point representing an exhibit are non-integers.
The figure below (left) illustrates eight items arranged in [0, 4] × [0, 4] (the second sample input). In the room, up to eight sender-receiver pairs can be mounted. The figure to the right shows an area protected by three sender-receiver pairs.

输入
Next K lines follow, each of which consists of two real numbers x, y describing the exhibit coordinates.
You can assume that 0 < x < N, 0 < y < M and that x and y are non-integer.
输出
样例输入
- 2
- 1 5 3
- 0.2 1.5
- 0.3 4.8
- 0.4 3.5
- 4 4 8
- 0.7 0.5
- 1.7 0.5
- 2.8 1.5
- 3.7 0.5
- 2.2 3.6
- 2.7 2.7
- 1.2 2.2
- 1.2 2.7
样例输出
- 1
- 3
【分析】给出一个矩形的长和宽,现有一些光线,其宽度为1,边界都在整数处,然后给出一些点的坐标,
都为小数。问最少需要多少光线可以将所有点覆盖住。
很容易想到最小点覆盖集,对于建图,可以看每个点所在的横坐标纵坐标(向上取整),然后连边,
再用最小点覆盖集模板。最小点覆盖集==最大匹配数。
- #include <iostream>
- #include <cstring>
- #include <cstdio>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #include <map>
- #include <queue>
- #include <vector>
- #define inf 0x7fffffff
- #define met(a,b) memset(a,b,sizeof a)
- typedef long long ll;
- using namespace std;
- const int N = ;
- const int M = ;
- int read() {
- int x=,f=;
- char c=getchar();
- while(c<''||c>'') {
- if(c=='-')f=-;
- c=getchar();
- }
- while(c>=''&&c<='') {
- x=x*+c-'';
- c=getchar();
- }
- return x*f;
- }
- int n1,n2,k;
- int mp[N][N],vis[N],link[N];
- int dfs(int x) {
- for(int i=; i<=n2; i++) {
- if(mp[x][i]&&!vis[i]) {
- vis[i]=;
- if(link[i]==-||dfs(link[i])) {
- link[i]=x;
- return ;
- }
- }
- }
- return ;
- }
- int main()
- {
- int cas ;
- scanf("%d\n",&cas);
- while(cas--) {
- int s=;
- scanf("%d%d%d",&n1,&n2,&k);
- met(mp,);
- double x,y;
- for(int i=; i<k; i++) {
- scanf("%lf%lf",&x,&y);
- int xx=int(x)+;
- int yy=int(y)+;
- mp[xx][yy]=;
- }
- memset(link,-,sizeof(link));
- for(int i=; i<=n1; i++) {
- memset(vis,,sizeof(vis));
- if(dfs(i)) s++;
- }
- printf("%d\n",s);
- }
- return ;
- }
Jewelry Exhibition(最小点覆盖集)的更多相关文章
- ACM/ICPC 之 机器调度-匈牙利算法解最小点覆盖集(DFS)(POJ1325)
//匈牙利算法-DFS //求最小点覆盖集 == 求最大匹配 //Time:0Ms Memory:208K #include<iostream> #include<cstring&g ...
- POJ2226 Muddy Fields(二分图最小点覆盖集)
题目给张R×C的地图,地图上*表示泥地..表示草地,问最少要几块宽1长任意木板才能盖住所有泥地,木板可以重合但不能盖住草地. 把所有行和列连续的泥地(可以放一块木板铺满的)看作点且行和列连续泥地分别作 ...
- POJ1325 Machine Schedule(二分图最小点覆盖集)
最小点覆盖集就是在一个有向图中选出最少的点集,使其覆盖所有的边. 二分图最小点覆盖集=二分图最大匹配(二分图最大边独立集) 这题A机器的n种模式作为X部的点,B机器的m种模式作为Y部的点: 每个任务就 ...
- POJ 2226 Muddy Fields (最小点覆盖集,对比POJ 3041)
题意 给出的是N*M的矩阵,同样是有障碍的格子,要求每次只能消除一行或一列中连续的格子,最少消除多少次可以全部清除. 思路 相当于POJ 3041升级版,不同之处在于这次不能一列一行全部消掉,那些非障 ...
- POJ 3041 Asteroids (最小点覆盖集)
题意 给出一个N*N的矩阵,有些格子上有障碍,要求每次消除一行或者一列的障碍,最少消除多少次可以全部清除障碍. 思路 把关键点取出来:一个障碍至少需要被它的行或者列中的一个消除. 也许是最近在做二分图 ...
- hdu 1054(最小点覆盖集)
Strategic Game Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 二分图变种之最小路径覆盖、最小点覆盖集【poj3041】【poj2060】
[pixiv] https://www.pixiv.net/member_illust.php?mode=medium&illust_id=54859604 向大(hei)佬(e)势力学(di ...
- POJ 3041 Asteroids (二分图最小点覆盖集)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 24789 Accepted: 13439 Descr ...
- hdu 1498(最小点覆盖集)
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
随机推荐
- 房子里的K2 BPM业务流程管理
房…子这件事上,尴尬实在太多. ಥ_ಥ 职场新人,租房很尴尬: 未婚男女,婚房很尴尬: 有下一代的,学区房很尴尬: 耄耋之年,养老房很尴尬... ▽ 甭管买房.租房.装修.设计,关于房子的尴尬事,三天 ...
- Python应用与实践
http://www.cnblogs.com/skynet/archive/2013/05/06/3063245.html
- Yslow&PageSpeed– 诊断各种缓慢症状
Google的PageSpeed和yahoo的yslow是各位不可少的前端工具(同样也都是firebug的插件,安装了firebug之后才可以拥有她们),当各位无法用三寸不烂之舌收拾产品和各种大佬的时 ...
- pyqt5 笔记(三)py2exe 实现代码打包exe
python3.4 安装64位的版本 py2exe 下载地址: https://pypi.python.org/pypi/py2exe/0.9.2.0#downloads cmd——>进入pyf ...
- 使用开源工具MonoDevelop开发GTK#图形界面
转自:http://developer.51cto.com/art/201011/235040.htm Mono一直到现在的2.8已经完全可以胜任一些比较小的项目了,但相关的开发文档与教程一直比较匮乏 ...
- 2016-1-9 Quartz框架的学习,剪裁图片并设置边框
#import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...
- BZOJ 3224 普通平衡树
这个是第一份完整的treap代码.嗯...虽然抄的百度的版,但还是不错的. !bzoj上不能用srand. #include<iostream>#include<cstdio> ...
- Python OpenCV —— Border
关于border的部分,边缘处理. # -*- coding: utf-8 -*- """ Created on Wed Sep 28 00:58:51 2016 @au ...
- 【Tsinghua OJ】循环移位(Cycle)
Description Cycle shifting refers to following operation on the sting. Moving first letter to the en ...
- Codeforces Round #365 (Div. 2)-D Mishka and Interesting sum(树状数组)
题目链接:http://codeforces.com/contest/703/problem/D 思路:看了神犇的代码写的... 偶数个相同的数异或结果为0,所以区间ans[l , r]=区间[l , ...