当前位置: 首页 > news >正文

UVA11853-Paintball(对偶图)

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

 

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

 

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cstdlib>
 5 #include <cmath>
 6 using namespace std;
 7 const int maxn = 1000+5;
 8 const double wide = 1000.0;
 9 
10 struct Point{
11     double x,y,r;
12 }point[maxn];
13 
14 bool intersection(Point &a,Point &b){
15     return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)) <= a.r+b.r;
16 }
17 
18 int n;
19 bool vis[maxn];
20 double Left,Right;
21 
22 void check_circle(int a){
23     if(point[a].x-point[a].r < 0) Left = min(Left,point[a].y-sqrt(point[a].r*point[a].r-point[a].x*point[a].x));
24     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)));
25 }
26 
27 bool dfs(int u){
28     if(vis[u]) return false;
29     vis[u] = true;
30     if(point[u].y-point[u].r < 0) return true;
31     for(int v = 1;v <= n;v++){
32         if(v==u || vis[v]) continue;
33         if(intersection(point[u],point[v]) && dfs(v)) return true;
34     }
35     check_circle(u);
36     return false;
37 }
38 
39 int main()
40 {
41     //freopen("input.txt","r",stdin);
42     while(~scanf("%d",&n)){
43         memset(vis,false,sizeof(vis));
44         Left = Right = wide;
45         for(int i = 1;i <= n;i++){
46             scanf("%lf%lf%lf",&point[i].x,&point[i].y,&point[i].r);
47         }
48         bool ok = true;
49         for(int i = 1;i <= n;i++){
50             if(!vis[i] && point[i].y+point[i].r>=wide && dfs(i)){
51                 ok = false;
52                 break;
53             }
54         }
55         if(ok) printf("%.2f %.2f %.2f %.2f\n",0.000,Left,wide,Right);
56         else printf("IMPOSSIBLE\n");
57     }
58     return 0;
59 }

 

转载于:https://www.cnblogs.com/npugen/p/9520797.html

相关文章:

  • vue版 文字滚动
  • 面试题:合并两个排序的链表
  • .NET CORE 第一节 创建基本的 asp.net core
  • 3ds Max学习日记(九)
  • 【Linux】time+dd测试硬盘读写速度
  • [洛谷P2801]教主的魔法
  • 共享服务-FTP基础(一)
  • ZYNQ的Linux Linaro系统镜像制作SD卡启动
  • intellij idea 编译 kafka 源码
  • 杂项-Java:Druod Monitor
  • mysql+centos7+主从复制
  • BZOJ1052 [HAOI2007]覆盖问题
  • RabbitMQ消息中介之Python使用
  • Android下的一些命令
  • Xshell连接虚拟机文档教程
  • 【159天】尚学堂高琪Java300集视频精华笔记(128)
  • 2019年如何成为全栈工程师?
  • Angular数据绑定机制
  • HashMap剖析之内部结构
  • k8s如何管理Pod
  • Phpstorm怎样批量删除空行?
  • Promise面试题2实现异步串行执行
  • rc-form之最单纯情况
  • spring cloud gateway 源码解析(4)跨域问题处理
  • vue2.0一起在懵逼的海洋里越陷越深(四)
  • 阿里云购买磁盘后挂载
  • 半理解系列--Promise的进化史
  • 基于 Babel 的 npm 包最小化设置
  • 突破自己的技术思维
  • 微信开放平台全网发布【失败】的几点排查方法
  • 移动端解决方案学习记录
  • d²y/dx²; 偏导数问题 请问f1 f2是什么意思
  • Python 之网络式编程
  • 完善智慧办公建设,小熊U租获京东数千万元A+轮融资 ...
  • ​Spring Boot 分片上传文件
  • (C语言)二分查找 超详细
  • (delphi11最新学习资料) Object Pascal 学习笔记---第5章第5节(delphi中的指针)
  • (附源码)springboot学生选课系统 毕业设计 612555
  • (机器学习的矩阵)(向量、矩阵与多元线性回归)
  • (剑指Offer)面试题41:和为s的连续正数序列
  • (十一)JAVA springboot ssm b2b2c多用户商城系统源码:服务网关Zuul高级篇
  • (算法)求1到1亿间的质数或素数
  • (一)kafka实战——kafka源码编译启动
  • . Flume面试题
  • .FileZilla的使用和主动模式被动模式介绍
  • .NET 4.0网络开发入门之旅-- 我在“网” 中央(下)
  • .NET BackgroundWorker
  • .NET Core 中插件式开发实现
  • .NET 中让 Task 支持带超时的异步等待
  • .NET3.5下用Lambda简化跨线程访问窗体控件,避免繁复的delegate,Invoke(转)
  • .Net6 Api Swagger配置
  • .NET6 命令行启动及发布单个Exe文件
  • @AutoConfigurationPackage的使用
  • [ C++ ] STL_stack(栈)queue(队列)使用及其重要接口模拟实现
  • [Android]使用Retrofit进行网络请求