当前位置: 首页 > news >正文

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;
}

相关文章:

  • JavaWeb使用Session防止表单重复提交
  • redis高级(分布式缓存实现,spring integration)
  • iOS 参考 网络书籍
  • react redux 登陆拦截
  • 细谈多个平台编程与网页设计切换启示录----my note
  • elasticsearch 性能监控基础
  • 企业内部DNS从服务器架构的步骤
  • select a method for export 选项
  • 使用JNI与原生代码的通信
  • Yii源码解读-服务定位器(Service Locator)
  • JAVA-JSP之include指令
  • xml 与dto的相互转换
  • ubuntu下安装cx_oracle
  • Android ViewPager使用详解
  • lateral view
  • (十五)java多线程之并发集合ArrayBlockingQueue
  • ➹使用webpack配置多页面应用(MPA)
  • 2017前端实习生面试总结
  • AWS实战 - 利用IAM对S3做访问控制
  • happypack两次报错的问题
  • IDEA常用插件整理
  • js面向对象
  • Linux链接文件
  • ng6--错误信息小结(持续更新)
  • Vue 2.3、2.4 知识点小结
  • 案例分享〡三拾众筹持续交付开发流程支撑创新业务
  • 解决iview多表头动态更改列元素发生的错误
  • 判断客户端类型,Android,iOS,PC
  • 正则学习笔记
  • ​linux启动进程的方式
  • ​ssh-keyscan命令--Linux命令应用大词典729个命令解读
  • #经典论文 异质山坡的物理模型 2 有效导水率
  • #快捷键# 大学四年我常用的软件快捷键大全,教你成为电脑高手!!
  • #微信小程序:微信小程序常见的配置传值
  • (poj1.2.1)1970(筛选法模拟)
  • (Redis使用系列) Springboot 整合Redisson 实现分布式锁 七
  • (层次遍历)104. 二叉树的最大深度
  • (附源码)springboot金融新闻信息服务系统 毕业设计651450
  • (深度全面解析)ChatGPT的重大更新给创业者带来了哪些红利机会
  • (数位dp) 算法竞赛入门到进阶 书本题集
  • (转)linux 命令大全
  • (最完美)小米手机6X的Usb调试模式在哪里打开的流程
  • .htaccess配置重写url引擎
  • .net经典笔试题
  • .NET使用HttpClient以multipart/form-data形式post上传文件及其相关参数
  • .net知识和学习方法系列(二十一)CLR-枚举
  • @Repository 注解
  • @TableId注解详细介绍 mybaits 实体类主键注解
  • []常用AT命令解释()
  • []利用定点式具实现:文件读取,完成不同进制之间的
  • [2009][note]构成理想导体超材料的有源THz欺骗表面等离子激元开关——
  • [AS3]URLLoader+URLRequest+JPGEncoder实现BitmapData图片数据保存
  • [C++参考]拷贝构造函数的参数必须是引用类型
  • [CareerCup] 13.1 Print Last K Lines 打印最后K行
  • [E链表] lc83. 删除排序链表中的重复元素(单链表+模拟)