HDU 5298 Solid Geometry Homework 暴力
Solid Geometry Homework
题目连接:
http://acm.hdu.edu.cn/showproblem.php?pid=5298
Description
Yellowstar is studying solid geometry recently,and today’s homework is about the space,plane and sphere.So he draw many planes and spheres in the draft paper.These infinite planes and (the surface of)spheres divides the whole drawing space(which can be considered as a infinite 3D-space) into many disjoint regions.Planes and spheres forms the borders of these regions,and they don’t belong to any regions.
Then he comes up with a crazy idea:color the whole space with crayons.He wants that one region has only one color,and two adjacent regions should be colored differently (“adjacent” means the area of two regions’ common borders is greater than zero).Unfortunately,he has only two crayons:a yellow one and a red one.
Yellowstar likes yellow very much,so he gives some coordinates.The regions these points belong to should be colored yellow.
Given positions of all the planes and spheres and the coordinates mentioned above.You should determine:Is there a way to satisfy all the requests?Yellowstar also gives some other coordinates.He wants to know which color they will be while all the requests are satisfied.
Input
The first line contains an integer T,denoting the number of the test cases.
For each test case, the first line contains 4 integers m,n,p and q, denoting the number of planes,spheres,points and queries.
Then m lines follows,each containing four integers a,b,c and d,denoting the linear equation(ax+by+cz+d=0) of this plane.|a|+|b|+|c|>0.
Then n lines follows,each containing four integers x,y,z and r,denoting the center coordinate(x,y,z) and radius of this sphere.
Then p lines follows, each containing three integers x,y,z,denoting point(x,y,z),the region it belongs to should be colored yellow.
Next q lines are queries.Each contains three integers x,y,z-the coordinate of this point.You need to output which color it will be.
T<=30,0<=m<=100,0<=n<=10,0<=p<=200,1<=q<=2000,|all given numbers|<=10^6,any two planes or spheres aren’t coincidence.No point lies on given planes or spheres.
There is a blank line before each case.
Output
For each case,if there is no such a coloring way to color the whole space and meet all the requests,print“Impossible”.
Otherwise,for each query,print a line.If the color of this point can be certainly inferred,print it(’Y’ for yellow or ’R’ for red);if not(both are possible),print”Both”.
Print a blank line between adjacent cases.
Sample Input
3
1 1 1 2
0 0 1 0
0 0 0 2
0 0 1
0 0 -1
0 0 4
1 1 2 1
0 0 1 0
0 0 0 2
0 0 1
0 0 -1
0 0 4
1 1 0 2
0 0 1 0
0 0 0 2
0 0 4
0 0 -1
Sample Output
R
R
Impossible
Both
Both
Hint
题意
在一个三维平面上有一堆平面,有一堆圆,然后这些玩意儿把平面切成了很多块。
然后每一块要么是红色,要么是黄色。
相邻的两块颜色不同。
现在已知p个点的颜色是黄色。
然后问你接下来q个点的颜色是啥。
题解:
首先其实这个空间的颜色分布已经被那p个点唯一确认了。
所以我们只要知道一个区域的颜色就好了。
因为只有两种颜色,判断一个点的颜色只要知道和这些圆的位置关系和这些平面的位置关系就好了。
然后这道题就结束了……
大概就是这样 喵。
代码
#include<bits/stdc++.h>
using namespace std;
struct node
{
long long a,b,c,d;
}plane[120],circle[12],P[2005],P2[205];
int n,m,p,q;
int check_plane(node A,node B)
{
return A.a*B.a+A.b*B.b+A.c*B.c+A.d>0?1:0;
}
int check_cirle(node A,node B)
{
return (A.a-B.a)*(A.a-B.a)+(A.b-B.b)*(A.b-B.b)+(A.c-B.c)*(A.c-B.c)>A.d*A.d?1:0;
}
int check(node a)
{
int ans = 0;
for(int i=0;i<m;i++)
ans^=check_plane(plane[i],a);
for(int i=0;i<n;i++)
ans^=check_cirle(circle[i],a);
return ans;
}
void solve()
{
scanf("%d%d%d%d",&m,&n,&p,&q);
for(int i=0;i<m;i++)
scanf("%lld%lld%lld%lld",&plane[i].a,&plane[i].b,&plane[i].c,&plane[i].d);
for(int i=0;i<n;i++)
scanf("%lld%lld%lld%lld",&circle[i].a,&circle[i].b,&circle[i].c,&circle[i].d);
if(p==0){
for(int i=0;i<q;i++)
{
scanf("%lld%lld%lld",&P[i].a,&P[i].b,&P[i].c);
printf("Both\n");
}
return;
}
for(int i=0;i<p;i++)
scanf("%lld%lld%lld",&P2[i].a,&P2[i].b,&P2[i].c);
for(int i=0;i<q;i++)
scanf("%lld%lld%lld",&P[i].a,&P[i].b,&P[i].c);
int flag = check(P2[0]);
for(int i=0;i<p;i++)
if(check(P2[i])^flag==1)
{
printf("Impossible\n");
return;
}
for(int i=0;i<q;i++)
{
if(check(P[i])^flag==1)
printf("R\n");
else
printf("Y\n");
}
}
int main()
{
int t;scanf("%d",&t);
while(t--)
{
solve();
if(t)puts("");
}
return 0;
}
HDU 5298 Solid Geometry Homework 暴力的更多相关文章
- HDU 2920 分块底数优化 暴力
其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^ ...
- hdu 4932 Miaomiao's Geometry(暴力枚举)
pid=4932">Miaomiao's Geometry ...
- hdu 5277 YJC counts stars 暴力
YJC counts stars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- hdu 4712 Hamming Distance(随机函数暴力)
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hdu 4876 ZCC loves cards(暴力)
题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...
- HDU 5442 Favorite Donut(暴力 or 后缀数组 or 最大表示法)
http://acm.hdu.edu.cn/showproblem.php?pid=5442 题意:给出一串字符串,它是循环的,现在要选定一个起点,使得该字符串字典序最大(顺时针和逆时针均可),如果有 ...
- HDU 5273 Dylans loves sequence 暴力递推
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5273 bc:http://bestcoder.hdu.edu.cn/contests/con ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...
随机推荐
- python基本数据类型list,tuple,set,dict用法以及遍历方法
1.list类型 类似于java的list类型,数据集合,可以追加元素与删除元素. 遍历list可以用下标进行遍历,也可以用迭代器遍历list集合 建立list的时候用[]括号 import sys ...
- 2. 数据库文件配置与简单操作 Model / M()
官方文档说明位置: Thinkphp/Conf/convention.php 内容说明如下: 'DB_TYPE' => '', // 数据库类型 'DB_HOST' => '', // 服 ...
- webgote的例子(5)Sql注入(Blog)
SQL Injection - Stored (Blog) (本章内容):留言板的注入 看到这个页面先看以下这个页面是做什么的.进行正常的写入发现我每写一句话,其内容都会写到下面的entry里面 在尝 ...
- mac 上 sublime text2 快捷键
打开/前往: ⌘T 前往文件 ⌘⌃P 前往项目⌘R 前往 method⌘⇧P 命令提示⌃G 前往行⌃ ` python 控制台 编辑:⌘L 选择行 (重复按下将下一行加入选择)⌘D 选择词 (重复按下 ...
- SSD回归类物体检测
本宝宝最近心情不会,反正这篇也是搬用别人博客的了:(SSD就是YOLO+anchor(不同feature map 作为input)) 引言 这篇文章是在YOLO[1]之后的一篇文章,这篇文章目前是一篇 ...
- 三十分钟理解:线性插值,双线性插值Bilinear Interpolation算法
线性插值 先讲一下线性插值:已知数据 (x0, y0) 与 (x1, y1),要计算 [x0, x1] 区间内某一位置 x 在直线上的y值(反过来也是一样,略): y−y0x−x0=y1−y0x1−x ...
- linux中使用vim编译C++程序
Vi三种模式详解 命令行模式 (command mode/一般模式) 任何时候,不管用户处于何种模式,只要按一下“ESC”键,即可使Vi进入命令行模式:我们在shell环境(提示符为$)下输入启动Vi ...
- Median of Two Sorted Arrays——算法课上经典的二分和分治算法
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...
- 并发queue
在并发队列上JDK提供了两套实现,一个是以ConcurrentLinkedQueue为代表的高性能队列,一个是以BlockingQueue接口为代表的阻塞队列,无论哪种都继承自Queue. 一.Con ...
- UI自动化的痛点
解决UI自动化难点痛点: 解决从安装过程中跳出的提示框以及操作过程中任意提示框的操作,来提高用例成功率: 公用用例及业务用例分离,便于维护和多人使用,提高脚本编写效率: 解决用android wind ...