【计算几何】【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 ...
随机推荐
- new操作符的内部运行解析
在加上new操作符,我们就能完成传统面向对象的class + new的方式创建对象,在Javascript中,我们将这类方式成为Pseudoclassical. 基于上面的例子,我们执行如下代码 ...
- Java——关于static关键字的那些事总结
前言: 先说说今天为啥要谈这个东西,虽然学Java已经有两年了,但是今天,本着温故而知新的态度,仔细的第三次翻看了<Head Firt Java>这本书,虽然这本书介绍的很多东西都特别基础 ...
- Java案例之士兵作战功能实现
实现的功能比较简单,主要用到了多态的,抽象类以及模板方法模式这几个知识点.效果图如下,哈哈 ,大神勿喷,后面我会把这些知识点详细介绍出来,即使Java学的不好,只要有一点其他语言基础或者没有应该都能看 ...
- C# 读写XML文件示例
using System; using System.Collections.Generic; using System.Text; using System.Configuration; using ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...
- aspxgridview只编辑某一列然后更新
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IsAllowDeliver ...
- C语言inline函数(转)
原文链接:http://blog.csdn.net/yuan1125/article/details/6225993 1 inline只是个编译器建议,编译器不一定非得展开Inline函数. 例如: ...
- JPA注解一对多报Could not determine type for: java.util.List错误
在原来的项目上加新功能,启动后报Caused by: org.hibernate.MappingException: Could not determine type for: java.util.L ...
- java获取项目路径,url路径
我的web项目名iamgeModel. 工作空间在D盘 先获取url相关: 需要是HttpServletRequest request; 获取IP: request.getServerName() / ...
- linux命令(20):rm命令
1. 强行删除文件,系统不再确认:rm –f test.log 2. 删除任何.log文件:rm *.log 3. 将test子目录及子目录中所有档案删除:rm –r test 4. 将 test子 ...