HDOJ 5298 Solid Geometry Homework
2015-08-02 16:55
225 查看
空间染色。。。找到数学上的关系就不难了。。。
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 100005; struct Plane { LL a, b, c, d; }a[maxn]; struct Circle { LL x, y, z, r; }b[maxn]; struct Point { LL x, y, z; Point(LL x = 0, LL y = 0, LL z = 0) : x(x), y(y), z(z) {} }; int n, m, p, q; bool f1(Plane t1, Point t2) { return t1.a * t2.x + t1.b * t2.y + t1.c * t2.z + t1.d > 0; } bool f2(Circle t1, Point t2) { LL t = (t1.x - t2.x) * (t1.x - t2.x) + (t1.y - t2.y) * (t1.y - t2.y) + (t1.z - t2.z) * (t1.z - t2.z); return t > t1.r * t1.r; } bool f(Point t1) { bool res = 0; for(int i = 1; i <= n; i++) res ^= f1(a[i], t1); for(int i = 1; i <= m; i++) res ^= f2(b[i], t1); return res; } void work() { LL x, y, z; scanf("%d%d%d%d", &n, &m, &p, &q); for(int i = 1; i <= n; i++) scanf("%lld%lld%lld%lld", &a[i].a, &a[i].b, &a[i].c, &a[i].d); for(int i = 1; i <= m; i++) scanf("%lld%lld%lld%lld", &b[i].x, &b[i].y, &b[i].z, &b[i].r); if(p == 0) { for(int i = 1; i <= q; i++) { scanf("%lld%lld%lld", &x, &y, &z); printf("Both\n"); } return; } int res = 0, ok = 1; scanf("%lld%lld%lld", &x, &y, &z); res = f(Point(x, y, z)); for(int i = 2; i <= p; i++) { scanf("%lld%lld%lld", &x, &y, &z); int t = f(Point(x, y, z)); if(t != res) ok = 0; } if(ok == 0) { for(int i = 1; i <= q; i++) scanf("%lld%lld%lld", &x, &y, &z); printf("Impossible\n"); return; } for(int i = 1; i <= q; i++) { scanf("%lld%lld%lld", &x, &y, &z); int t = f(Point(x, y, z)); if(t == res) printf("Y\n"); else printf("R\n"); } } int main() { int _; scanf("%d", &_); for(int i = 1; i <= _; i++) { work(); if(i != _) printf("\n"); } return 0; }
相关文章推荐
- 北大ACM3233——Matrix Power Series
- System类的学习
- IOS StoryBoard简单说明
- osgi 运行错误
- Kotlin语言文档翻译项目
- Fragment的练习
- [leetcode] 216.Combination Sum III
- 并查集
- HDU 1870.愚人节的礼物【字符串处理】【思维练习】【8月2】
- Ip 子网掩码 物理地址 验证
- shell编程
- 我对建立时间和保持时间的理解
- HDU 1279 士兵队列训练问题
- hdu2147巴什博弈
- 华为是怎样研发的(5)——白板讲解
- Eclipse之CTRL+左键直接进入方法函数Implementation
- [深入理解Android卷一全文-第十章]深入理解MediaScanner
- Zookeeper命令
- BootStrap下拉按钮
- hdu2363Cycling 二分+最短路