hdu 5298 Solid Geometry Homework(几何)
来源:互联网 发布:淘宝网副总裁张勤 编辑:程序博客网 时间:2024/05/17 03:23
题目链接:hdu 5298 Solid Geometry Homework
每个圈或者是平面将划分出两个区域,每次把一边区域取反即可。最后判断一下是否满足。
#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;const int maxn = 3000;typedef long long ll;struct Point {int type;ll x, y, z;Point (int type = 0, ll x = 0, ll y = 0, ll z = 0) {this->type = type;this->x = x;this->y = y;this->z = z;}};struct Shape {int type;ll a, b, c, d;Shape (int type = 0, ll a = 0, ll b = 0, ll c = 0, ll d = 0) {this->type = type;this->a = a;this->b = b;this->c = c;this->d = d;}bool judge (Point u) {if (type) {ll ta = u.x - a, tb = u.y - b, tc = u.z - c;return ta * ta + tb * tb + tc * tc - d * d > 0;}return a * u.x + b * u.y + c * u.z + d > 0;}};int M, N, P, Q, V[maxn];vector<Shape> s;vector<Point> p;void init () {s.clear();p.clear();memset(V, 0, sizeof(V));ll a, b, c, d;scanf("%d%d%d%d", &M, &N, &P, &Q);for (int i = 0; i < M; i++) {scanf("%lld%lld%lld%lld", &a, &b, &c, &d);s.push_back(Shape(0, a, b, c, d));}for (int i = 0; i < N; i++) {scanf("%lld%lld%lld%lld", &a, &b, &c, &d);s.push_back(Shape(1, a, b, c, d));}for (int i = 0; i < P; i++) {scanf("%lld%lld%lld", &a, &b, &c);p.push_back(Point(0, a, b, c));}for (int i = 0; i < Q; i++) {scanf("%lld%lld%lld", &a, &b, &c);p.push_back(Point(1, a, b, c));}}void solve () {if (P == 0) {for (int i = 0; i < Q; i++)printf("Both\n");return;}for (int i = 0; i < s.size(); i++) {for (int j = 0; j < p.size(); j++) {if (s[i].judge(p[j]))V[j] ^= 1;}}int yellow = -1;for (int i = 0; i < p.size(); i++) {if (p[i].type == 0) {if (yellow == -1)yellow = V[i];else if (yellow != V[i]) {printf("Impossible\n");return;}}}for (int i = 0; i < p.size(); i++) {if (p[i].type) {printf("%s\n", V[i] == yellow ? "Y" : "R");}}}int main () {int cas;scanf("%d", &cas);while (cas--) {init();solve();if (cas)printf("\n");}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-6242:Geometry Problem(随机化+几何)
- 问题六十六:怎么用ray tracing画CSG(Constructive Solid Geometry 构造实体几何)图形
- HDU 6242 Geometry Problem (随机数,几何)
- HDU 6242 Geometry Problem(2017 CCPC 哈理工)(随机化+计算几何)
- hdu 1086 You can Solve a Geometry Problem too(计算几何水题)
- hdu 1086 You can Solve a Geometry Problem too(几何(线段相交))
- HDU 1086 You can Solve a Geometry Problem too(计算几何)
- HDU 1086 You can Solve a Geometry Problem too (计算几何 判断线段相交)
- 计算几何(一道题) Geometry
- HDU 6242/2017CCPC哈尔滨 Geometry Problem 【随机化+计算几何】
- HDU 5605 geometry(水~)
- hdu(1074)Doing Homework
- Android大图片裁剪终极解决方案(下:拍照截图)
- 直接用socket实现HTTP下载
- mysql_fetch_array容易掉入的陷进
- 黑马程序员——走进面向对象
- NGUI(三)背包系统页面
- hdu 5298 Solid Geometry Homework(几何)
- PDM与Excel利用VB脚本进行互导
- ubuntu下搭建rust到intellij开发环境
- XML基本知识
- API注册表函数
- hdu 5299 Circles Game(博弈)
- 翻转子串
- oc构造方法
- 创建Struts2项目