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. python的Web框架,中间件middleware及djangoAdmin

    简介 用于处理request和response的中间处理的函数,可以创建在项目中的任意位置,只要可以导入即可. 建议创建在APP目录下,方便管理. 函数范式与激活 中间件的范式: # 必须接受get_ ...

  2. RocketMQ的broker启动失败解决

    RocketMQ的broker用如下命令启动: nohup sh bin/mqbroker -n localhost:9876 & 使用jps查看,系统非常卡顿,broker的名字也未显示.使 ...

  3. 利用shell显示wordcount功能

      Shell脚本编程是Linux系统最为核心的技术之一,它能够利用简单的命令来实现一些复杂的功能,同时,由于Linux提供了很多文本处理命令,如grep(grep family), tr, sed, ...

  4. (整理)Sublime Text 3 安装、破解、安装Package Control、汉化、添加到右键菜单、代码格式化、禁止更新

    Sublime Text 3好用,但是每次安装到最后用着顺手,得在网上找半天安装.破解.安装Package Control.汉化.添加到右键菜单.代码格式化等等的教程,今天有空给自己整理一下吧. 一. ...

  5. jQuery文档操作方法对比和src写法

    jQuery文档操作方法对比 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  6. 微信服务号获取openid方法

    public function tetst(){ if(!isset($_GET['code'])){ $APPID = $this->app_id; $ran = rand(1,100); / ...

  7. 初学HTML-6

    表单:专门用来收集用户信息 表单元素:在HTML中,标签/标记/元素都是指HTML中的标签. eg:<a>a标签/a标记/a元素 浏览器中所以得表单标签都有特殊的外观和默认的功能. 格式: ...

  8. setTimeout.js

    var cyn = function(){ console.log("我是延时输出的函数") } setTimeout(cyn,5000)

  9. POM、STS、IOC、DI、AOP

    POM:全称:poject object model 说明:项目对象模型.maven用来管理项目的依赖.编译.文档等信息 STS: 全称:spring tool suite 说明:spring 基于e ...

  10. 洛谷P4555 [国家集训队]最长双回文串(manacher 线段树)

    题意 题目链接 Sol 我的做法比较naive..首先manacher预处理出以每个位置为中心的回文串的长度.然后枚举一个中间位置,现在要考虑的就是能覆盖到i - 1的回文串中 中心最靠左的,和能覆盖 ...