Problem UVA11853-Paintball

Accept:229  Submit:1830

Time Limit: 3000 mSec

Problem Description

You are playing paintball on a 1000×1000 square field. A number of your opponents are on the field hiding behind trees at various positions. Each opponent can fire a paintball a certain distance in any direction. Can you cross the field without being hit by a paintball? Assume that the southwest corner of the field is at (0,0) and the northwest corner at (0,1000).

 Input

The input contains several scenario. Each scenario consists of a line containing n ≤ 1000, the number of opponents. A line follows for each opponent, containing three real numbers: the (x,y) location of the opponent and its firing range. The opponent can hit you with a paintball if you ever pass within his firing range. You must enter the field somewhere between the southwest and northwest corner and must leave somewhere between the southeast and northeast corners.

 Output

For each scenario, if you can complete the trip, output four real numbers with two digits after the decimal place, the coordinates at which you may enter and leave the field, separated by spaces. If you can enter and leave at several places, give the most northerly. If there is no such pair of positions, print the line:‘IMPOSSIBLE’

 Sample Input

3
500 500 499
0 0 999
1000 1000 200
 
 

 Sample Ouput

0.00 1000.00 1000.00 800.00

题解:这个题思路比较奇特,有了对偶图的思路,这个题就基本上是个水题了。题目问的时能过去,反过来考虑,怎样不能过去。把正方形区域想象成湖,各个士兵形成的攻击范围看作一个个踏板,如果能够从上边界走到下边界,那么整个图就被分成了左右两部分,自然不能从左到右。并且这个条件时充要的,因此可以作为判据。之后就是如何找最北边。只看左边,如果某个踏板从上边界的踏板出发不能够到达,那该踏板就不对入口坐标造成影响,反过来,如果能到达,并且该踏板和左边界右交点,那么沿着它的上交点就能走回上边界,相当于左上角这一块被包围了,自然入口在下面,据此得到结论,只需要找出从上边界出发能到达的圆,计算出这些圆和左边界交点的最小值就是最北的入口,右边界同理。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
const int maxn = +;
const double wide = 1000.0; struct Point{
double x,y,r;
}point[maxn]; bool intersection(Point &a,Point &b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)) <= a.r+b.r;
} int n;
bool vis[maxn];
double Left,Right; void check_circle(int a){
if(point[a].x-point[a].r < ) Left = min(Left,point[a].y-sqrt(point[a].r*point[a].r-point[a].x*point[a].x));
if(point[a].x+point[a].r > wide) Right = min(Right,point[a].y-sqrt(point[a].r*point[a].r-(wide-point[a].x)*(wide-point[a].x)));
} bool dfs(int u){
if(vis[u]) return false;
vis[u] = true;
if(point[u].y-point[u].r < ) return true;
for(int v = ;v <= n;v++){
if(v==u || vis[v]) continue;
if(intersection(point[u],point[v]) && dfs(v)) return true;
}
check_circle(u);
return false;
} int main()
{
//freopen("input.txt","r",stdin);
while(~scanf("%d",&n)){
memset(vis,false,sizeof(vis));
Left = Right = wide;
for(int i = ;i <= n;i++){
scanf("%lf%lf%lf",&point[i].x,&point[i].y,&point[i].r);
}
bool ok = true;
for(int i = ;i <= n;i++){
if(!vis[i] && point[i].y+point[i].r>=wide && dfs(i)){
ok = false;
break;
}
}
if(ok) printf("%.2f %.2f %.2f %.2f\n",0.000,Left,wide,Right);
else printf("IMPOSSIBLE\n");
}
return ;
}

UVA11853-Paintball(对偶图)的更多相关文章

  1. 【DFS】Paintball(6-22)

    [UVA11853]Paintball 算法入门经典第6章6-22(P175) 题目大意:有一个1000*1000的正方形战场,西南角坐标(0,0),西北角坐标(0,1000),有n个敌人,每个敌人处 ...

  2. bzoj 1001狼抓兔子(对偶图+最短路)最大流

    推荐文章:<浅析最大最小定理在信息学竞赛中的应用>--周冬 题目 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的, 而且现在的兔子还 ...

  3. BZOJ1001: [BeiJing2006]狼抓兔子 [最小割 | 对偶图+spfa]

    1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 19528  Solved: 4818[Submit][ ...

  4. 【BZOJ-2007】海拔 最小割 (平面图转对偶图 + 最短路)

    2007: [Noi2010]海拔 Time Limit: 20 Sec  Memory Limit: 552 MBSubmit: 2095  Solved: 1002[Submit][Status] ...

  5. 【BZOJ-4423】Bytehattan 并查集 + 平面图转对偶图

    4423: [AMPPZ2013]Bytehattan Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 144  Solved: 103[Submit][ ...

  6. 【BZOJ 1001】狼抓兔子 对偶图+SPFA

    这道题是求图的最小割,也就是用最大流.但因为边太多,最大流算法会T,因此不能用最大流算法. 因为这是个平面图,所以求平面图的最小割可以使用特殊的技巧就是求对偶图然后求对偶图的最短路.把每个面看成一个点 ...

  7. BZOJ-1001 狼抓兔子 (最小割-最大流)平面图转对偶图+SPFA

    1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec Memory Limit: 162 MB Submit: 14686 Solved: 3513 [Submit][ ...

  8. 对偶图 && 【BZOJ】1001: [BeiJing2006]狼抓兔子(对偶图+最短路)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1001 可谓惨不忍睹,一下午就在调这题了. 很久以前看到这题是一眼最大流,看到n<=1000,我 ...

  9. bzoj 4423 [AMPPZ2013]Bytehattan(对偶图,并查集)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4423 [题意] 给定一个平面图,随时删边,并询问删边后两点是否连通.强制在线. [科普 ...

随机推荐

  1. [AHOI2008] 紧急集合

    Description 欢乐岛上有个非常好玩的游戏,叫做"紧急集合".在岛上分散有N个等待点,有N-1条道路连接着它们,每一条道路都连接某两个等待点,且通过这些道路可以走遍所有的等 ...

  2. python程序编写中常见错误

    1,NameError语法错误 s还没定义,给s赋值就行了 2,IndexError 索引错误 对于列表l1来说,只有4个元素,所以l1的Index只能是0-3,当你所输入的Index不在这范围,就会 ...

  3. C++ 输入、输出运算符重载

    C++ 能够使用流提取运算符 >> 和流插入运算符 << 来输入和输出内置的数据类型.我们可以重载流提取运算符和流插入运算符来操作对象等用户自定义的数据类型. 在这里,有一点很 ...

  4. 服务器CPU居高不下--解决问题历程

    基本的概述 在一个服务器的集群上面,服务器的CPU长时间居高不下,响应的时间也一直很慢,即使扩容了服务器CPU的下降效果也不是很明显. 对于CPU过高的原因,可以总结到以下原因: 太多的循环或者死循环 ...

  5. scala 基础

    1.scala一些预热操作 1.1 to 是一个方法,()可以进行 参数传递,map()把每一个元素取出来进行相应的操作,  print(1.to(10).map(_*10))  结果  Vector ...

  6. Java学习笔记之——静态方法

    1.方法的定义 定义在类中,方法是独立的 2.语法: public static 返回值类型 方法名(形参列表){ 方法中的具体代码: } 1)方法名:在同一个类中方法名不能重复    命名规则:驼峰 ...

  7. Java学习笔记之——Java介绍

    1.Java体系: JavaSE:标准版,其他两个体系的基础 JavaEE:企业版 JavaME:微型版,适用于消费类型的微型设备 2.Java三大特性:封装.继承.多态 3.Java的特点:面向对象 ...

  8. 深入理解Java 8 Lambda(类库篇)

    背景(Background) 自从lambda表达式成为Java语言的一部分之后,Java集合(Collections)API就面临着大幅变化.而 JSR 355(规定了 Java lambda 表达 ...

  9. 关于IOS下click事件委托失效的解决方案

    一.由于某些特殊情况下,需要用到事件委托,比如给动态创建的DOM绑定click事件,这里就需要事件委托(这里就牵扯到:目标元素和代理元素)目标元素:动态创建的元素,最终click事件需要绑定到该元素 ...

  10. Layui treeGrid

    目前treeGrid的源码不是很完善, 没有开放, 只有社区里面有, 想用的可以看看下面方法: 1.加入treeGrid.js文件 (1)layui 的treeGrid 下载地址:    https: ...