1245. Pictures

Time limit: 1.0 second
Memory limit: 64 MB
Artist Ivanov (not the famous Ivanov who painted "Christ's apparition to people", but one of the many namesakes) once managed to rent inexpensively an excellent studio. Alas, as he soon discovered, the inexpensiveness was caused by objective reasons. A murder happened long ago in the house where he rented the room, and now the ghost living in the house each night renews blood spots on the walls of all the rooms. Ivanov's studio did not escape this damnation.
Nevertheless, being a creative person, Ivanov quickly found a simple solution to the problem. He decided to paint one or two pictures and hang them on the (single) wall where the spots appear each night so that the spots would be covered by the pictures. Of course, he does not want to spend too much time doing this work. That is why he plans to use not more than two pictures and wants the total area of the pictures to be minimal.
All the blood spots are circles. Each picture has a rectangular form with sides parallel to the axes, and the minimally possible size of a picture in each of the dimensions is 100 millimeters. If it is necessary to paint two pictures, then they should be hanged to the wall without overlaying. Each spot must be covered by exactly one picture.

Input

The first line contains the number of the spots N, 0 < N ≤ 1000. Each of the next N lines contains the description of the corresponding spot. A spot is described by three positive integers; they are the radius of the spot and the Cartesian coordinates of the center of the spot. Everything is measured in millimeters and all these numbers do not exceed 10000.

Output

Output the minimal total area (in square millimeters) of the pictures (not more than two) necessary to cover all the spots.

Sample

input output
3
50 50 50
50 250 50
10 150 250
40000
Problem Author: Alexander Petrov (text — Leonid Volkov)
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
Difficulty: 898
 
题意:平面上有一些圆,半径ri,圆心(xi,yi),问用不超过两个矩阵覆盖他们的最小面积。注意:一个圆不能被两个矩形覆盖。
分析:显然,因为一个圆不能被两个矩形覆盖,瞬间变的简单。
矩形边界必为某个圆的上下左右的切线。
枚举即可。
 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name)
{
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = , M = ;
struct Point
{
int x, y, r; inline void Read()
{
r = Getint();
x = Getint();
y = Getint();
} inline bool operator <(const Point &A) const
{
return x < A.x;
}
} Arr[N];
int n;
int LU[N], LD[N], RU[N], RD[N], Left[N], Right[N];
int Ans = MIT; inline void Input()
{
n = Getint();
For(i, , n) Arr[i].Read();
} inline void Work()
{
sort(Arr + , Arr + + n);
Right[] = -INF, LD[] = INF, LU[] = -INF;
For(i, , n)
{
Right[i] = max(Right[i - ], Arr[i].x + Arr[i].r);
LU[i] = max(LU[i - ], Arr[i].y + Arr[i].r);
LD[i] = min(LD[i - ], Arr[i].y - Arr[i].r);
}
Left[n + ] = INF, RD[n + ] = INF, RU[n + ] = -INF;
Ford(i, n, )
{
Left[i] = min(Left[i + ], Arr[i].x - Arr[i].r);
RU[i] = max(RU[i + ], Arr[i].y + Arr[i].r);
RD[i] = min(RD[i + ], Arr[i].y - Arr[i].r);
} For(i, , n)
if(Right[i - ] <= Left[i])
Ans = min(Ans,
max(M, Right[i - ] - Left[]) * max(M, LU[i - ] - LD[i - ]) +
max(M, Right[n] - Left[i]) * max(M, RU[i] - RD[i]));
} inline void Solve()
{
Work();
For(i, , n) swap(Arr[i].x, Arr[i].y);
Work(); Ans = min(Ans, max(M, Right[n] - Left[]) * max(M, LU[n] - LD[n])); printf("%d\n", Ans);
} int main()
{
#ifndef ONLINE_JUDGE
SetIO("D");
#endif
Input();
Solve();
return ;
}

ural 1245. Pictures的更多相关文章

  1. AC日记——最小的N个和 codevs 1245

    1245 最小的N个和  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 有两个长度为 N ...

  2. codevs 1245 最小的N个和

    1245 最小的N个和 http://codevs.cn/problem/1245/ 题目描述 Description 有两个长度为 N 的序列 A 和 B,在 A 和 B 中各任取一个数可以得到 N ...

  3. XUT 1245

    这是一道2016湘潭邀请赛的题目,记得那个时候看到这个题目就想到了最短生成树,然后给别人做,WA了,最后发现是有向图,然后我自己去写了个搜索,结果是RE吧 今天刚刚好想到这个题目,然后再来做,发现这个 ...

  4. 1245 - Harmonic Number (II)---LightOJ1245

    http://lightoj.com/volume_showproblem.php?problem=1245 题目大意:一个数n除以1到n之和 分析:暴力肯定不行,我们可以先求1~sqrt(n)之间的 ...

  5. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  6. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  7. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  8. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  9. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

随机推荐

  1. Java Session 介绍;

    为什么需要Session 这是为了填补 Http 协议的局限,当用户去访问一个页面,服务端返回完了请求(如,你访问完一个网页,这个页面将页面内容,界面UI呈现给你),就算是结束了,就断开了,服务端不再 ...

  2. 在rails下新建表

    (文章都是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 今天需要新建表,以下是建表语句 rails generate scaffold users ema ...

  3. poj1611(感染病患者)

    The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 24587   Accepted: 12046 De ...

  4. jquery博客收集的IE6中CSS常见BUG全集及解决方案

    今天的样式调的纠结,一会这边一会那么把jquery博客折腾的头大,浏览器兼容性.晚上闲着收集一些常见IE6中的BUG 3像素问题及解决办法 当使用float浮动容器后,在IE6下会产生3px的空隙,有 ...

  5. ubuntu下sh文件使用

    可把shell命令批处理写进filename.sh文件 然后执行 chmod +x filename.sh 就可以执行./filename.sh了

  6. MQTT——安装、测试

    MQTT学习笔记——MQTT协议体验 Mosquitto安装和使用         http://blog.csdn.net/xukai871105/article/details/39252653 ...

  7. 【转】如何用 Chrome for Android 做远程遥控 debugging

    http://blog.csdn.net/wuchengzhi82/article/details/22190435

  8. iOS 中NSOperationQueue,Grand Central Dispatch , Thread的上下关系和区别

    In OS X v10.6 and later, operation queues use the libdispatch library (also known as Grand Central D ...

  9. 六间房PK同时观看两方视频(绕过VIP限制)+直播状态批量监测

    可交换两个视频位置,记住最后播放记录,游客VIP限制也能观看视频等功能. 使用方法: 1.先运行 6.cn.live.exe 分别打开两个主播房间的网页(VIP限制也能获取视频的文件名) (房间已满提 ...

  10. [Android Pro] 超能RecyclerView组件使用

    RecyclerView最强大的功能在于秒变功能,只需要改动很少的代码就可以实现ListView,GridView及水平ListViw的切换功能 public class MainActivity e ...