三维空间中有一些(<=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的更多相关文章

  1. HDU 4380 Farmer Greedy 计算几何+bitset

    枚举直线,对于直线的某个点在直线的左端还是右端,能够状压出一个数.用bitset记录. 然后三角形就是3个bitset&一下 #include <cstdio> #include ...

  2. LOJ#6049. 「雅礼集训 2017 Day10」拍苍蝇(计算几何+bitset)

    题面 传送门 题解 首先可以用一个矩形去套这个多边形,那么我们只要枚举这个矩形的左下角就可以枚举完所有多边形的位置了 我们先对每一个\(x\)坐标开一个\(bitset\),表示这个\(x\)坐标里哪 ...

  3. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  4. Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset

    Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  5. Codeforces Gym 100342J Problem J. Triatrip bitset 求三元环的数量

    Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/att ...

  6. ZOJ 3203 Light Bulb (三分+计算几何)

    B - Light Bulb Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit ...

  7. hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)

    Mirror and Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. Rasheda And The Zeriba Gym - 100283A  计算几何

    http://codeforces.com/gym/100283/problem/A 考虑到多边形是不稳定的,是可以变来变去的. 那么总是可以把每个点放到圆上. 所以只需要判断圆心角是不是小于等于36 ...

  9. F - Filter Gym - 100553F (bitset用法)

    题目链接:http://codeforces.com/gym/100553/attachments/download/2885/20142015-acmicpc-northeastern-europe ...

随机推荐

  1. WinRAR分割超大文件

    在自己的硬盘上有一个比较大的文件,想把它从网上通过E-Mail发送给朋友时,却发现对方的收信服务器不能够支持那么大的文件……,这时即使用ZIP等压缩软件也无济于事,因为该文件本身已经被压缩过了.于是许 ...

  2. golang中 return如果返回指针比大型struct性能高

    type tt struct{ aa int bb int cc int str string } func func_rstruct () tt{ t:=tt{1,2,3,"8888888 ...

  3. 【POJ3254】coinfield

    状压dp初步. #include<iostream> #include<cstdio> #include<cstring> #include<algorith ...

  4. 【bzoj4033】HAOI2015树上染色

    树形dp. #include<bits/stdc++.h> #define N 2010 using namespace std; typedef long long ll; ,head[ ...

  5. [会装]Spark standalone 模式的安装

    1. 简介 以standalone模式安装spark集群bin运行demo. 2.环境和介质准备 2.1 下载spark介质,根据现有hadoop的版本选择下载,我目前的环境中的hadoop版本是2. ...

  6. 关于进度管理工具Gantt图

    关于进度管理工具Gantt图 18.以下关于进度管理工具图的叙述中,不正确的是( D). A.能清晰地表达每个任务的开始时间.结束时间和持续时间 B.能清晰地表达任务之间的并行关系 C.不能清晰地确定 ...

  7. asp.net的Server.MapPath方法

    Server.MapPath()的功能: 返回与 Web 服务器上的指定虚拟路径相对应的物理文件路径. 命名空间: System.Web 程序集: System.Web(在 System.Web.dl ...

  8. 限制输入字符个数的jq插件

    (function($) { $.fn.extend( { limiter: function(limit, elem) { $(this).on("keyup focus", f ...

  9. Ubuntu上开启Apache Rewrite功能的方法

    Ubuntu上开启Apache Rewrite功能的方法 本文介绍ubuntn系统中开启apache的urlrewrite功能的方法. 在Windows上开启Apache的urlRewrite非常简单 ...

  10. python3连接使用sqlite3

    一直比较喜欢sqlite,业余爱好不需要大型数据库,原来在windows下最常用的就是access,使用很方便,但是linux下没法用,后 来从php+sqlite2开始使用,编程时间很少,代码量很小 ...