Bear and Floodlight 状态压缩DP啊
| Time Limit: 4000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
Description
One day a bear lived on the Oxy axis. He was afraid of the dark, so he couldn't move at night along the plane points that aren't lit. One day the bear wanted to have a night walk from his house at point (l, 0) to his friend's house at point (r, 0), along the segment of length (r - l). Of course, if he wants to make this walk, he needs each point of the segment to be lit. That's why the bear called his friend (and yes, in the middle of the night) asking for a very delicate favor.
The Oxy axis contains n floodlights. Floodlight i is at point (xi, yi) and can light any angle of the plane as large as ai degree with vertex at point(xi, yi). The bear asked his friend to turn the floodlights so that he (the bear) could go as far away from his house as possible during the walking along the segment. His kind friend agreed to fulfill his request. And while he is at it, the bear wonders: what is the furthest he can go away from his house? Hep him and find this distance.
Consider that the plane has no obstacles and no other light sources besides the floodlights. The bear's friend cannot turn the floodlights during the bear's walk. Assume that after all the floodlights are turned in the correct direction, the bear goes for a walk and his friend goes to bed.
Input
The first line contains three space-separated integers n, l, r(1 ≤ n ≤ 20; - 105 ≤ l ≤ r ≤ 105). The i-th of the next n lines contain three space-separated integers xi, yi, ai( - 1000 ≤ xi ≤ 1000; 1 ≤ yi ≤ 1000; 1 ≤ ai ≤ 90) — the floodlights' description.
Note that two floodlights can be at the same point of the plane.
Output
Print a single real number — the answer to the problem. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 6.
Sample Input
2 3 5
3 1 45
5 1 45
2.000000000
1 0 1
1 1 30
0.732050808
1 0 1
1 1 45
1.000000000
1 0 2
0 2 90
2.000000000
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define PI acos(-1)
#define eps 0.0000000001
struct point
{
double x,y,a;
};
point p[];
double dp[<<];
double dist(double x,double y,double x1,double y1)
{
return sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
}
double solve(double s,int k)
{
double B=atan2(p[k].y,p[k].x-s),A=p[k].a*PI/;
double C=max(0.0,PI-A-B),l=dist(s,0.0,p[k].x,p[k].y);
//cout<<A<<" "<<B<<" "<<C<<" "<<s+l*sin(A)/sin(C)<<endl;
return s+l*sin(A)/sin(C);
}
int main()
{
// freopen("in.txt","r",stdin);
int n,i,size,j,ok;
double l,r;
while(~scanf("%d%lf%lf",&n,&l,&r))
{
ok=;
for(i=;i<n;i++)
{
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].a);
if(p[i].y<)p[i].y=-p[i].y;
}
size=<<n;
for(i=;i<size;i++)dp[i]=l;
for(i=;!ok&&i<size;i++)
{
for(j=;!ok&&j<n;j++)
{
if(i&(<<j))
continue;
dp[i|(<<j)]=max(dp[i|(<<j)],solve(dp[i],j));
if(dp[i|(<<j)]>=r)ok=;
}
}
if(ok)
{
printf("%.9lf\n",r-l);
//cout<<"YES"<<endl;
}
else
printf("%.9lf\n",dp[(<<n)-]-l);
}
}
Bear and Floodlight 状态压缩DP啊的更多相关文章
- hoj2662 状态压缩dp
Pieces Assignment My Tags (Edit) Source : zhouguyue Time limit : 1 sec Memory limit : 64 M S ...
- POJ 3254 Corn Fields(状态压缩DP)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4739 Accepted: 2506 Descr ...
- [知识点]状态压缩DP
// 此博文为迁移而来,写于2015年7月15日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102w6jf.html 1.前 ...
- HDU-4529 郑厂长系列故事——N骑士问题 状态压缩DP
题意:给定一个合法的八皇后棋盘,现在给定1-10个骑士,问这些骑士不能够相互攻击的拜访方式有多少种. 分析:一开始想着搜索写,发现该题和八皇后不同,八皇后每一行只能够摆放一个棋子,因此搜索收敛的很快, ...
- DP大作战—状态压缩dp
题目描述 阿姆斯特朗回旋加速式阿姆斯特朗炮是一种非常厉害的武器,这种武器可以毁灭自身同行同列两个单位范围内的所有其他单位(其实就是十字型),听起来比红警里面的法国巨炮可是厉害多了.现在,零崎要在地图上 ...
- 状态压缩dp问题
问题:Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Ev ...
- BZOJ-1226 学校食堂Dining 状态压缩DP
1226: [SDOI2009]学校食堂Dining Time Limit: 10 Sec Memory Limit: 259 MB Submit: 588 Solved: 360 [Submit][ ...
- Marriage Ceremonies(状态压缩dp)
Marriage Ceremonies Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- HDU 1074 (状态压缩DP)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1074 题目大意:有N个作业(N<=15),每个作业需耗时,有一个截止期限.超期多少天就要扣多少 ...
随机推荐
- jmeter后置处理器 JSON Extractor取多个变量值
1.需要获取响应数据的请求右键添加-后置处理器-JSON Extractor 2.如果要获取json响应数据多个值时,设置的Variable names (后续引用变量值的变量名设置)与JSON Pa ...
- HandlerThread实现数字时钟
1.描述 刚看完Android多线程编程,对HandlerThread比较感兴趣,趁热巩固练习,实现一个了数字时钟,希望对学习HandlerThread有所帮助.如下: 启动一个HandlerThre ...
- 走近RDD
RDD(Resilient Distributed Datasets)弹性分布式数据集.RDD可以看成是一个简单的"数组",对其进行操作也只需要调用有限的"数组" ...
- 关于querySelector 和 document.getElementsByTagName 选中集合问题
本文解决的问题是 :运用for..of..循环时,edge浏览器报Object doesn't support property or method 'symbol.iterator'问题 以及 符号 ...
- C++ 将函数作为形参
今天偶然看到一段代码,其中将函数作为形参进行设计,一开始不理解,自己试了一下,发现果然可行 #include <iostream> using namespace std; void vi ...
- linux bash 和 sh的区别
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt189 Linux 中的 shell 有很多类型,其中最常用的几种是: Bou ...
- [转]RMI方式Ehcache集群的源码分析
RMI方式Ehcache集群的源码分析 Ehcache不仅支持基本的内存缓存,还支持多种方式将本地内存中的缓存同步到其他使用Ehcache的服务器中,形成集群.如下图所示: Ehcache支持 ...
- poj 1014多重背包
题意:给出价值为1,2,3,4,5,6的6种物品数量,问是否能将物品分成两份,使两份的总价值相等. 思路:求出总价值除二,做多重背包,需要二进制优化. 代码: #include<iostream ...
- JSONP(Json with padding)
JSONP:一种非官方跨域数据交互协议 JSONP怎么产生的 JSONP的原理 看上面的来源加以理解 上面说过了,script是不受跨域影响的 那么我们可以在我们代码中引用B服务器的文件 <sc ...
- PS各个工具的字母快捷键和英…
原文地址:PS各个工具的字母快捷键和英文全名作者:Tycho 选框-Marquee(M) 移动-move(V) 套索-Lasso(L) 魔棒-Wand(W) 喷枪-in ...