【以前的空间】bzoj 1052 [HAOI2007]覆盖问题
这道题的思路挺简单的……就是可以证明如果要覆盖一个区域内的点,那么一定有一个正方形在这“区域内的点所围成的最大矩形的四个角中的一个”(不要吐槽很多的“的”……),对于长度r是否可以覆盖整个区域内的点,只需要先枚举第一个矩形在“区域内的点所围成的最大矩形的四个角中的哪一个”,然后再枚举下一个点在“区域内的剩余点所围成的最大矩形的四个角中的哪一个”第三个正方形就直接判断余下的点的最大最小差值是否小于r就行了……再然后就直接二分答案了……然后,注意一种情况,就是出现一个或者两个矩形就可以覆盖完整个区域点的情况(可能是因为我傻×于是就被这里坑了一下)……
type
arr=record
x,y:longint;
end;
var
a:array[..]of arr;
i,j,k,l,r,n,mid,maxx,minx,maxy,miny:longint;
vs:array[..]of longint; procedure find(var x1,x2,y1,y2:longint);
begin
x1:=-maxlongint;
x2:=maxlongint;
y1:=-maxlongint;
y2:=maxlongint;
for i:= to n do if vs[i]= then
begin
if a[i].x>x1 then x1:=a[i].x;
if a[i].x<x2 then x2:=a[i].x;
if a[i].y>y1 then y1:=a[i].y;
if a[i].y<y2 then y2:=a[i].y;
end;
end; function dfs(x,y:longint):boolean;
var
maxx,minx,maxy,miny:longint;
begin
find(maxx,minx,maxy,miny);
if minx=maxlongint then exit(true);
if y= then begin
if (maxx-minx<=x) and (maxy-miny<=x) then exit(true);
exit(false);
end; for i:= to n do
if vs[i]= then
if (minx+x>=a[i].x) and (miny+x>=a[i].y) then vs[i]:=y;
if dfs(x,y+) then exit(true);
for i:= to n do
if vs[i]=y then vs[i]:=; for i:= to n do
if vs[i]= then
if (minx+x>=a[i].x) and (maxy-x<=a[i].y) then vs[i]:=y;
if dfs(x,y+) then exit(true);
for i:= to n do
if vs[i]=y then vs[i]:=; for i:= to n do
if vs[i]= then
if (maxx-x<=a[i].x) and (miny+x>=a[i].y) then vs[i]:=y;
if dfs(x,y+) then exit(true);
for i:= to n do
if vs[i]=y then vs[i]:=; for i:= to n do
if vs[i]= then
if (maxx-x<=a[i].x) and (maxy-x<=a[i].y) then vs[i]:=y;
if dfs(x,y+) then exit(true);
for i:= to n do
if vs[i]=y then vs[i]:=;
exit(false);
end; begin
readln(n);
for i:= to n do
readln(a[i].x,a[i].y);
fillchar(vs,sizeof(vs),);
find(maxx,minx,maxy,miny);
l:=;
if maxx-minx>maxy-miny
then r:=maxx-minx
else r:=maxy-miny;
while l<=r do begin
fillchar(vs,sizeof(vs),);
mid:=(l+r)>>;
if dfs(mid,) then r:=mid-
else l:=mid+;
end;
writeln(l);
readln;
end.
【以前的空间】bzoj 1052 [HAOI2007]覆盖问题的更多相关文章
- BZOJ 1052: [HAOI2007]覆盖问题
BZOJ 1052: [HAOI2007]覆盖问题 题意:给定平面上横纵坐标在-1e9~1e9内的20000个整数点的坐标,用三个大小相同边平行于坐标轴的正方形覆盖(在边界上的也算),问正方形的边长最 ...
- [BZOJ 1052][HAOI2007]覆盖问题(二分答案)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1052 分析: 挺有想法的一道题,先二分答案ans,主要是判断的问题. 首先可以弄出把所 ...
- BZOJ 1052 HAOI2007 覆盖问题 二分法答案+DFS
标题效果:特定n点.涵盖所有的点与同方三面.斧头要求方垂直边界,最小平方的需求方长值 最大值至少.答案是很明显的二分法 但验证是一个问题 考虑仅仅有三个正方形,故用一个最小矩形覆盖这三个正方形时至少有 ...
- 【BZOJ 1052】 1052: [HAOI2007]覆盖问题 (乱搞)
1052: [HAOI2007]覆盖问题 Description 某人在山上种了N棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄 膜把这些小树遮盖起来,经过一番长久的 ...
- 【BZOJ】1052: [HAOI2007]覆盖问题
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1052 大概自己YY了个贪心然后过了... 二分答案,考虑如何check: 找到一个最小的矩 ...
- 【BZOJ】1052: [HAOI2007]覆盖问题(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=1052 首先膜拜题解orz,表示只能想到二分... 贪心就是每一次找到一个最小的能包围所有点的矩阵,然 ...
- 1052: [HAOI2007]覆盖问题 - BZOJ
Description 某人在山上种了N棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄膜把这些小树遮盖起来,经过一番长久的思考,他决定用3个L*L的正方形塑料薄膜将小 ...
- [BZOJ1052][HAOI2007]覆盖问题 二分+贪心
1052: [HAOI2007]覆盖问题 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2053 Solved: 959 [Submit][Sta ...
- 二分判定 覆盖问题 BZOJ 1052
//二分判定 覆盖问题 BZOJ 1052 // 首先确定一个最小矩阵包围所有点,则最优正方形的一个角一定与矩形一个角重合. // 然后枚举每个角,再解决子问题 #include <bits/s ...
随机推荐
- 一个CookieContainer的拓展类
最近项目中需要频繁用到服务器返回的Cookie,由于项目采用的是HttpClient,并且用CookieContainer自动托管Cookie,在获取Cookie的时候不太方便.所以就写了个拓展类. ...
- 对网页进行截图(selenium)
import os def insert_img(driver,file_name): #获取当前路径,并转换为字符串 base_dir=str(os.path.dirname(__file__)) ...
- Kotlin对象:仅一行代码就可创建安全的单例
作者:Antonio Leiva 时间:Jun 20, 2017 原文链接:https://antonioleiva.com/objects-kotlin/ Kotlin对象是Android开发人员不 ...
- 使用httpClient获取请求cookie
package mytest; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValueP ...
- 【转】关于cocos2dx+lua注册事件函数详解
转载:http://www.taikr.com/article/1605 registerScriptTouchHandler 注册触屏事件registerScriptTapHandler注册点击事件 ...
- 《Effective C++》读书笔记 条款03 尽可能使用const 使代码更加健壮
如果你对const足够了解,只需记住以下结论即可: 将某些东西声明为const可帮助编译器侦测出错误用法,const可被施加于任何作用于内的对象.函数参数.函数返回类型.成员函数本体. 编译器强制实施 ...
- LeetCode - 231. Power of Two - 判断一个数是否2的n次幂 - 位运算应用实例 - ( C++ )
1.题目:原题链接 Given an integer, write a function to determine if it is a power of two. 给定一个整数,判断该整数是否是2的 ...
- POJ 3415 Common Substrings(后缀数组)
Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given t ...
- 20145214 《Java程序设计》第5周学习总结
20145214 <Java程序设计>第5周学习总结 教材学习内容总结 try和catch Java中所有错误都会被包装为对象,可以尝试try执行程序并捕捉catch代表错误的对象后做一些 ...
- Alpha冲刺——第一天
Alpha第一天 听说 031502543 周龙荣(队长) 031502615 李家鹏 031502632 伍晨薇 031502637 张柽 031502639 郑秦 1.前言 任务分配是VV.ZQ. ...