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. [POJ1936]All in All

    [POJ1936]All in All 试题描述 You have devised a new encryption technique which encodes a message by inse ...

  2. redhat 6 / centos 6 搭建Django环境

    1)首先 安装的时候  到 选择安装那些包的时候 把 编译环境和开发的包 那块全部打上勾 2)系统虽然自带Python安装包,但是版本比较低.所以推荐自行进行tar包编译安装比较新的 https:// ...

  3. BZOJ2904

    找了一个晚上的资料,拼凑出来这么一个东西: 1) 如果是完全平方数返回12) 如果可以表示成形如$x^2+y^2$的形式输出2.这要求该数质因数分解后形如$4k+3$的质因数次数都是偶数.3) 如果该 ...

  4. php获取网页内容方法总结

    抓取到的内容在通过正则表达式做一下过滤就得到了你想要的内容,至于如何用正则表达式过滤,在这里就不做介绍了,有兴趣的,以下就是几种常用的用php抓取网页中的内容的方法. 1.file_get_conte ...

  5. Android Services重点记录

    今天阅读了google的官方文档 Services,对重点做下记录. 首先,Services默认运行在主线程中,所以一般情况下,要手动创建一个thread. 系统除了Services,还为我们提供了一 ...

  6. Java for LeetCode 070 Climbing Stairs

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  7. 字母排列_next_permutation_字典序函数_待解决

    问题 B: 字母排列 时间限制: 1 Sec  内存限制: 64 MB提交: 19  解决: 5[提交][状态][讨论版] 题目描述 当给出一串字符时,我们逐个可以变换其字符,形成新的字符串.假如对这 ...

  8. 【转载】C++ 值传递、指针传递、引用传递详解

    原文链接:http://www.cnblogs.com/yanlingyin/ 值传递: 形参是实参的拷贝,改变形参的值并不会影响外部实参的值.从被调用函数的角度来说,值传递是单向的(实参->形 ...

  9. UML从需求到实现---类图(2)

    上节写到了UML中的类图:UML从需求到实现---类图(1) 写完以后总觉得写的不够详细.里面很多细节没有说到.一篇文章就把强大的面向对象的类说完.当然是不可能的.这次我再补充一些关于UML中类图和类 ...

  10. oracle11g客户端 安装图解

    软件位置:我的网盘 -- oracle空间 -- oracle工具 -- win64_11gR2_database_clint(客户端) -- 压缩软件包 先将下载下来的ZIP文件解压,并运行setu ...