Ural 1640 Circle of Winter【坑爹题。。。】

1640. Circle of Winter

Time Limit: 1.0 second
Memory Limit: 64 MB
Lich Sandro declared war to the King of Hell, and now hordes of demons are fighting fiercely against Sandro's army of the undead. Sandro has mastered the Magic of Fire, but the creatures of Hell can't be damaged by fire. That's why Sandro decided to use a “Circle of Winter” spell against them. This spell creates an indestructable circular-shaped ice wall. The demons who are touched by the circumference die immediately; the demons enclosed in a circle stay alive, but can't participate in the fight anymore.
Sandro can teleport to any point of the battlefield instantly and cast a “Circle of Winter” there. An ice wall centered in that point will appear in that case. Note that Sandro's magic skills allow him to cast a wall with a radius not exceeding 10000 metres. Now Sandro wants to choose a point to teleport to and a radius of a spell in such way that at least one demon would be killed and all the rest would be enclosed in a circle.

Input

The first line contains an integer n — the number of demons (1 ≤ n ≤ 100). Demons can be considered as points on the battlefield. The next n lines contain n pairs of space-separated integers (xy) — the coordinates of the demons relative to the point Sandro occupies before teleportation. Coordinates are given in metres and don't exceed 1000 in absolute value. Each point of the battlefield contains no more than one demon; also a demon can't occupy a point the Sandro occupies before teleportation.

Output

Output 3 real numbers precise up to 10−9 — the coordinates of a point Sandro should teleport to and the radius of a “Circle of Winter” he should create. Sandro can't teleport to a point that is occupied by a demon. It is guaranteed that the solution always exists.

Samples

inputoutput
7 
1 1
1 5
3 6
5 3
8 0
9 5
5 9
5 4 5
2 
0 2
2 0
1 1 1.41421356237309 
Problem Author: Dmitry Ivankov (prepared by Alexander Ipatov)
Problem Source: USU Junior Contest, October 2008
Tags: geometry



去年看到的时候就不会。今年会了最小覆盖圆的模板,试着做,结果依然WA,估计是找到的最小覆盖圆和给定的点中的某一个重复了。
仔细一想,试了试,竟然是坑爹题。
题目给你N个二维整点(坐标绝对值不大于1000),让你找一个点使这N个点中至少有一个在圆上,其他均在圆内,且圆半径小于10000,且圆心不与已知点重合。输出圆心坐标和半径(实数,精确到1e-9)

这题坑爹之处在于,不要求输出半径最小解。
那么即可随意构造解了。
只要任意实数解都可,因为题目给出的点都是整点。
这样你就令c.x = 0.1,c.y = 0.1,然后求出这个圆心到这N个点的最远距离,即为半径,然后AC。
我了个去。

代码:
#include <iostream>
#include 
<cstdio>
#include 
<cstring>
#include 
<cmath>
using namespace std;
#define maxn 105
const double eps = 1e-9;
double x[maxn],y[maxn],cx,cy,r;
int main()
{
    
int n;
    scanf(
"%d",&n);
    
for(int i = 0;i < n;i++)
        scanf(
"%lf %lf",&x[i],&y[i]);
    cx 
= cy = 0.1;
    r 
= 0.0;
    
for(int i = 0;i < n;i++)
        r 
= max(r,sqrt((cx - x[i]) * (cx - x[i]) + (cy - y[i]) * (cy - y[i])));
    printf(
"%.10lf %.10lf %.10lf\n",cx,cy,r);
}

posted on 2011-08-14 21:32 BUPT-[aswmtjdsj] @ Penalty 阅读(247) 评论(0)  编辑 收藏 引用 所属分类: 计算几何Ural Solution Report


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理


<2011年7月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

常用链接

留言簿(1)

随笔分类(150)

随笔档案(71)

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜