【计算几何】【bitset】Gym - 101412G - Let There Be Light
三维空间中有一些(<=2000)气球,一些光源(<=15),给定一个目标点,问你在移除不超过K个气球的前提下,目标点所能接受到的最大光照。
枚举每个光源,预处理其若要照射到光源,需要移走哪些气球,构建成一个bitset。
然后再2^15枚举光源集合,看看要让集合中所有光源照到目标点所要移走的气球是否在K以内,尝试更新答案。
需要注意的一点是,三维叉积叉出来的向量的长度的绝对值,就是原来两个向量所张成的平行四边形面积的大小。
#include<cstdio>
#include<cmath>
#include<bitset>
#include<iostream>
using namespace std;
bitset<2001>S[16],Ss;
const double EPS=0.0000001;
struct Point{
int x,y,z,t;
Point(const int &x,const int &y,const int &z,const int &t){
this->x=x;
this->y=y;
this->z=z;
this->t=t;
}
Point(const int &x,const int &y,const int &z){
this->x=x;
this->y=y;
this->z=z;
}
Point(){}
void read(){
scanf("%d%d%d%d",&x,&y,&z,&t);
}
double length(){
return sqrt((double)x*(double)x+(double)y*(double)y+(double)z*(double)z);
}
int length2(){
return x*x+y*y+z*z;
}
}ba[2010],lig[17],aim;
typedef Point Vector;
Vector operator - (const Point &a,const Point &b){
return Vector(a.x-b.x,a.y-b.y,a.z-b.z);
}
bool in(const Point &BA,const Point &p){
return (BA-p).length2()<BA.t*BA.t;
}
Vector Cross(const Vector &a,const Vector &b){
return Vector(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
int dot(const Vector &a,const Vector &b){
return a.x*b.x+a.y*b.y+a.z*b.z;
}
double DisToSegment(Point P,Point A,Point B)
{
Vector v1=B-A,v2=P-A,v3=P-B;
if(dot(v1,v2)<0) return (double)v2.length();
else if(dot(v1,v3)>0) return (double)v3.length();
else return fabs((double)Cross(v1,v2).length())/(double)v1.length();
}
int n,m,K;
double ans;
int main(){
// freopen("g.in","r",stdin);
while(1){
scanf("%d%d%d",&n,&m,&K);
if(!n && !m && !K){
return 0;
}
ans=0;
for(int i=1;i<=m;++i){
S[i].reset();
}
for(int i=1;i<=n;++i){
ba[i].read();
}
for(int i=1;i<=m;++i){
lig[i].read();
}
scanf("%d%d%d",&aim.x,&aim.y,&aim.z);
for(int i=1;i<=m;++i){
for(int j=1;j<=n;++j){
bool ina=in(ba[j],aim),inl=in(ba[j],lig[i]);
if((ina^inl) || ((!ina && !inl) && DisToSegment(ba[j],aim,lig[i])-(double)ba[j].t<EPS)){
S[i].set(j);
}
}
// for(int j=1;j<=n;++j){
// cout<<S[i][j];
// }
// puts("");
}
for(int i=0;i<(1<<m);++i){
double tmp=0;
Ss.reset();
for(int j=1;j<=m;++j){
if(i&(1<<(j-1))){
Ss|=S[j];
if(Ss.count()>K){
goto OUT;
}
tmp+=(double)lig[j].t/(double)(aim-lig[j]).length2();
}
}
ans=max(ans,tmp);
OUT:;
}
printf("%.10lf\n",ans);
}
return 0;
}
【计算几何】【bitset】Gym - 101412G - Let There Be Light的更多相关文章
- HDU 4380 Farmer Greedy 计算几何+bitset
枚举直线,对于直线的某个点在直线的左端还是右端,能够状压出一个数.用bitset记录. 然后三角形就是3个bitset&一下 #include <cstdio> #include ...
- LOJ#6049. 「雅礼集训 2017 Day10」拍苍蝇(计算几何+bitset)
题面 传送门 题解 首先可以用一个矩形去套这个多边形,那么我们只要枚举这个矩形的左下角就可以枚举完所有多边形的位置了 我们先对每一个\(x\)坐标开一个\(bitset\),表示这个\(x\)坐标里哪 ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- Codeforces Gym 100342J Problem J. Triatrip bitset 求三元环的数量
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/att ...
- ZOJ 3203 Light Bulb (三分+计算几何)
B - Light Bulb Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit ...
- hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)
Mirror and Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Rasheda And The Zeriba Gym - 100283A 计算几何
http://codeforces.com/gym/100283/problem/A 考虑到多边形是不稳定的,是可以变来变去的. 那么总是可以把每个点放到圆上. 所以只需要判断圆心角是不是小于等于36 ...
- F - Filter Gym - 100553F (bitset用法)
题目链接:http://codeforces.com/gym/100553/attachments/download/2885/20142015-acmicpc-northeastern-europe ...
随机推荐
- TOYS(计算几何基础+点与直线的位置关系)
题目链接:http://poj.org/problem?id=2318 题面: TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submiss ...
- AndroidStudio 添加Selector文件,在res文件夹下添加文件夹
在res文件夹下添加文件夹: 添加Selector文件:
- 重拾Object--(一)初识
Java中的Object类有着特殊的意义,他是所有其它类的父类,查看Object类的源代码,可以发现代码不多,逻辑也很简单. Java所有类的源代码我们都可以在JDK的文件中查看,在JDK下会有一个名 ...
- javascript中=、==与===的区别
1.等号 =赋值运算符,给变量赋值 var a="1"; 2.相等和不相等操作符 相等操作符由==表示,若两个操作数相等,则返回true:不相等操作符由!=表示,若两个操作数不相等 ...
- [NOIP2011]刷水
前几天做了NOIP2011的题,感觉不是那么难. 这边先做了两天的前两题,T3还没打. D1T1:顺次读入,分别判断是否覆盖即可,照例大水: #include<cstdio> ],b[], ...
- Qualcomm platform, the commonly used parameters of charger and battery in device tree file
Platform MSM8917 PM8937 PMI8940 Parameters 1 battery charging voltage : qcom,float-voltage-mv = < ...
- 安全测试===sqlmap(肆)转载
十八.杂项 1.使用简写 参数:-z 有些参数组合是被经常用到的,如“--batch --random-agent --ignore-proxy --technique=BEU”,这样写一大串很不好看 ...
- Java中volatile修饰符,不稳定标记的用法笔记
今天学java特性时,发现了volatile修饰符,这个修饰符修饰的变量告诉java编译器忽略优化机制,这样的优势是: java优化后,寄存器会缓存内存里的变量,另一个线程修改这个变量的内存时,不会同 ...
- 比特币编译(Ubuntu 16.04)
安装比特币需要的所有库 sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-de ...
- 数字签名(以ActiveXDemo为例)
1.创建Install.inf文件和run.bat Install.inf: [version] signature="$CHICAGO$" AdvancedINF=2.0 [Se ...