HDU 5298 Solid Geometry Homework(异或)
来源:互联网 发布:程序员试用期总结 编辑:程序博客网 时间:2024/06/06 15:47
官方题解说的挺详细的。。。
#include <algorithm>#include <iostream>#include <string.h>#include <stdlib.h>#include <assert.h>#include <stdio.h>#include <math.h>#include <queue>#include <set>#include <map>using namespace std;#define LL long long#define ULL unsigned long longstruct Plane { LL a, b, c, d; Plane() {} Plane(LL _a, LL _b, LL _c, LL _d): a(_a), b(_b), c(_c), d(_d) {}}pn[110];struct Sphere { LL x, y, z, r; Sphere() {} Sphere(LL _x, LL _y, LL _z, LL _r): x(_x), y(_y), z(_z), r(_r) {}}ss[20];struct Point { LL x, y, z; int val; Point() {} Point(LL _x, LL _y, LL _z, int _v): x(_x), y(_y), z(_z), val(_v) {}}pp[210];int sgn(LL x) { return x > 0 ? 1 : 0;}int main() {// freopen("hdoj5298.in", "r", stdin); int cas; scanf("%d", &cas); for(int t = 0; t < cas; t++) { if(t) puts(""); int m, n, p, q; scanf("%d%d%d%d", &m, &n, &p, &q); LL x, y, w, z; for(int i = 0; i < m; i++) { scanf("%I64d%I64d%I64d%I64d", &x, &y, &w, &z); pn[i] = Plane(x, y, w, z); } for(int i = 0; i < n; i++) { scanf("%I64d%I64d%I64d%I64d", &x, &y, &w, &z); ss[i] = Sphere(x, y, w, z); } for(int i = 0; i < p; i++) { scanf("%I64d%I64d%I64d", &x, &y, &z); pp[i] = Point(x, y, z, 0); } for(int i = 0; i < p; i++) { for(int j = 0; j < m; j++) pp[i].val ^= sgn(pp[i].x * pn[j].a + pp[i].y * pn[j].b + pp[i].z * pn[j].c + pn[j].d); for(int j = 0; j < n; j++) pp[i].val ^= sgn((pp[i].x - ss[j].x) * (pp[i].x - ss[j].x) + (pp[i].y - ss[j].y) * (pp[i].y - ss[j].y) + (pp[i].z - ss[j].z) * (pp[i].z - ss[j].z) - ss[j].r * ss[j].r); } int k; if(p) { int key = pp[0].val; for(k = 1; k < p; k++) if(pp[k].val != key) break; } int val; for(int i = 0; i < q; i++) { val = 0; scanf("%I64d%I64d%I64d", &x, &y, &z); if(p && k == p) { if(p) { for(int j = 0; j < m; j++) val ^= sgn(x * pn[j].a + y * pn[j].b + z * pn[j].c + pn[j].d); for(int j = 0; j < n; j++) val ^= sgn((x - ss[j].x) * (x - ss[j].x) + (y - ss[j].y) * (y - ss[j].y) + (z - ss[j].z) * (z - ss[j].z) - ss[j].r * ss[j].r); if(val == pp[0].val) puts("Y"); else puts("R"); } } if(!p) puts("Both"); } if(p && k != p) puts("Impossible"); } return 0;}
0 0
- HDU 5298 Solid Geometry Homework(异或)
- hdu 5298 Solid Geometry Homework(几何)
- hdu 5298 Solid Geometry Homework
- HDOJ 5298 Solid Geometry Homework
- 【HDU】5298 Solid Geometry Homework【暴力+二分图】
- 2015多校第一场1001 hdu 5298 Solid Geometry Homework
- HDU 5605 geometry(水~)
- hdu(1074)Doing Homework
- 问题六十六:怎么用ray tracing画CSG(Constructive Solid Geometry 构造实体几何)图形
- Constructive Solid Geometry with the Stencil Buffer
- HDU 4932 Miaomiao's Geometry(推理)
- hdu 2948 Geometry Darts(math)
- HDU-6242:Geometry Problem(随机化+几何)
- hdu 1789 Doing Homework again (贪心)
- hdu 1789 Doing Homework again(贪心)
- HDU 1789 Doing Homework again (贪心)
- HDU 1789 Doing Homework again (贪心)
- HDU 1789 Doing Homework again(贪心~!)
- 同步和信号量
- JavaScript向php传递参数
- 那些年,在nodejs上踩过的坑(一)
- Linux中替换文本中的字符串
- 439 - Knight Moves
- HDU 5298 Solid Geometry Homework(异或)
- iOS中使用七牛云存储Django服务端实现简单的图片上传功能
- java.sql.SQLException: Parameter metadata not available for the given statement
- C语言-变量的存储类别(auto, static, register, extern)
- Store Kit Guide(In App Purchase)翻译
- 暑假集训第四周阶段一 DP A - Robberies
- opencv——PNG格式图像读取转换函数
- C++第七节:继承
- 斐波那契数列四吧