poj 2296
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 2047 | Accepted: 682 |
Description
Assume that each city is a point on the plane, and its label is a text bounded in a square with edges parallel to x and y axis. The label of each city should be located such that the city point appears exactly in the middle of the top or bottom edges of the label. In a good labeling, the square labels are all of the same size, and no two labels overlap, although they may share one edge. Figure 1 depicts an example of a good labeling (the texts of the labels are not shown.)
Given the coordinates of all city points on the map as integer values, you are to find the maximum label size (an integer value) such that a good labeling exists for the map. 
Input
Output
Sample Input
1
6
1 1
2 3
3 2
4 4
10 4
2 5
Sample Output
2 最大化最小
利用二分法将问题转化为判定型,然后使用2-SAT就可以了 分析可知每个点只有两种情况,在正方形上面的中点和在正方形下面的中点。
首先e[i].x-e[j].x的绝对值小于diff才会有影响。
特殊情况是e[i].y==e[j].y,建4条边
而后e[i].y-e[j].y的绝对值小于diff时只能是一个向上一个向下,由此建两条边
然后就是e[i].y-e[j].y的绝对值小于diff时,那么如果上面的向下,下面的一定向下;同时下面的向上,那么上面的也一定向上,在由此建两条边就好了。
poj 2296的更多相关文章
- POJ 2296 Map Labeler / ZOJ 2493 Map Labeler / HIT 2369 Map Labeler / UVAlive 2973 Map Labeler(2-sat 二分)
POJ 2296 Map Labeler / ZOJ 2493 Map Labeler / HIT 2369 Map Labeler / UVAlive 2973 Map Labeler(2-sat ...
- POJ 2296 Map Labeler(2-sat)
POJ 2296 Map Labeler 题目链接 题意: 坐标轴上有N个点.要在每一个点上贴一个正方形,这个正方形的横竖边分别和x,y轴平行,而且要使得点要么在正方形的上面那条边的中点,或者在以下那 ...
- POJ 2296 二分+2-sat
题目大意: 给定n个点,给每个点都安排一个相同的正方形,使这个点落在正方形的下底边的中间或者上底边的中间,并让这n个正方形不出现相互覆盖,可以共享同一条边,求 这个正方形最大的边长 这里明显看出n个点 ...
- POJ 2296 Map Labeler
二分答案 + 2-SAT验证,判断正方形是否相交写起来有点烦,思路还是挺简单的. #include<cstdio> #include<cstring> #include< ...
- Map Labeler POJ - 2296(2 - sat 具体关系建边)
题意: 给出n个点 让求这n个点所能建成的正方形的最大边长,要求不覆盖,且这n个点在正方形上或下边的中点位置 解析: 当然是二分,但建图就有点还行..比较难想..行吧...我太垃圾... 2 - s ...
- POJ 2296 Map Labeler (2-Sat)
Map Labeler Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1267 Accepted: 409 Descri ...
- Map Labeler (poj 2296 二分+2-SAT)
Language: Default Map Labeler Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1815 Ac ...
- 【图论】2-sat总结
2-sat总结 2-sat问题,一般表现的形式为.每一个点有两种方式a,b,要么选a,要么选b.而且点点之间有一些约束关系.比如:u和v至少一个选a.那么这就是一个表达式.把a当成真,b当成假,那就是 ...
- 关于2-sat的建图方法及解决方案
转载增减: https://blog.csdn.net/qq_24451605/article/details/47126143 https://blog.csdn.net/u012915516/ar ...
随机推荐
- MYSQL 索引汇总
1.MySQL索引类型 先分以下类,MYQL有两大类索引:聚集索引和非聚集索引(只考虑mysql innodb) 聚集索引:在有主键的情况下,主键为聚集索引,其他都是非聚集索引 ...
- Vue Cli 3 打包上线 静态资源404问题解决方案
报错原因:静态资源丢失 解决方案 官方文档https://cli.vuejs.org/zh/config/#vue-config-js baseUrl 从 Vue CLI 3.3 起已弃用,请使用pu ...
- 有赞透明多级缓存解决方案(TMC)设计思路
引子 TMC 是什么 TMC,即"透明多级缓存(Transparent Multilevel Cache)",是有赞 PaaS 团队给公司内应用提供的整体缓存解决方案. TMC 在 ...
- Netty(六):NioServerSocketChannel源码解析
我们在Netty学习系列五的最后提出了一些问题还没得到回答,今天来通过学习NioServerSocketChannel的源码来帮我们找到之前问题的答案. 先看一下NioServerSocketChan ...
- Radix_Sort
public class Radix_sort { public static void sort(int[] arrays,int radix){ int n = 1; int length = a ...
- OpenCV的安装和使用
@ windows系统 (环境:VS2013) 下载安装opencv.exe: VS2013下“项目”->“属性页”->“配置属性”-> “VC++目录”: 包含目录 - ..\op ...
- Entity Framework使用EntityState和Attach来保存数据变化以及更新实体的个别字段
在使用Entity Framework作为ORM来存取数据的过程中,最常规的操作就是对数据对象的更新.本文将会包含如何Attach Entity到一个数据Context中,以及如何使用EntitySt ...
- Java笔记(day18-19)
泛型: jdk1.5出现的安全机制. 好处: 1,将运行时期的问题ClassCastException转到了编译时期. 2,避免了强制转换的麻烦. <>:当操作的引用数据类型不确定的时候. ...
- springboot配置静态资源访问路径
其实在springboot中静态资源的映射文件是在resources目录下的static文件夹,springboot推荐我们将静态资源放在static文件夹下,因为默认配置就是classpath:/s ...
- mongodb windows 集群搭建
准备三台机器,系统:windows 8 192.168.1.1 192.168.1.2 192.168.1.3 每台机器上安装mongodb 服务,步骤: 下载以下文件并依次执行安装 clearcom ...