计算几何水题。暴力搞

注意力全部都在02那里,完全没想这道题!

 /*--------------------------------------------------------------------------------------*/

 #include <algorithm>
#include <iostream>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <unordered_set>
#include <map> //debug function for a N*M array
#define debug_map(N,M,G) printf("\n");for(int i=0;i<(N);i++)\
{for(int j=;j<(M);j++){\
printf("%d",G[i][j]);}printf("\n");}
//debug function for int,float,double,etc.
#define debug_var(X) cout<<#X"="<<X<<endl;
#define LL long long
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int prime = ;
const int MOD = 1e9+; /*--------------------------------------------------------------------------------------*/
using namespace std; const int maxn = ;
int N,M,T; struct point{
int x,y,z;
point(int _x=,int _y=,int _z=):x(_x),y(_y),z(_z){} bool operator < (const point &rhs) const
{
if(y == rhs.y && x == rhs.x) return z < rhs.z;
else if(x == rhs.x) return y < rhs.y;
else return x < rhs.x;
}
point operator + (const point B) const
{
return point(x+B.x,y+B.y,z+B.z);
}
point operator - (const point B) const
{
return point(x-B.x,y-B.y,z-B.z);
}
int operator * (const point B) const
{
return x*B.x + y*B.y + z*B.z;
}
point operator ^ (const point B) const
{
return point(y*B.z - z*B.y,
z*B.x - x*B.z,
x*B.y - y*B.x);
}
}pt[maxn];
typedef point vec; struct node{
int id;
int dis;
bool operator < (const node &rhs) const
{
return dis < rhs.dis;
}
}; int dis(point a,point b)
{
return (a.x - b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z);
}
bool onPlane(point a,point b,point c,point d)
{
return ( ((a-c) ^ (a-d)) * (a-b) ) == ;
}
int _onPlane(point a,point b,point c,point d)
{
return ( ((a-c) ^ (a-d)) * (a-b) ) ;
} vector <node> ppt[maxn];
unordered_set <int > st; int myHash(LL a,LL b,LL c,LL d)
{
return ((((a*prime%MOD + b)*prime%MOD +c)*prime%MOD +d) + MOD )%MOD;
} int cas;
int main()
{
//freopen("input","r",stdin);
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
for(int i=,x,y,z;i<N;i++)
{
scanf("%d%d%d",&x,&y,&z);
pt[i].x = x;
pt[i].y = y;
pt[i].z = z;
} st.clear();
for(int i=;i<N;i++)
{
node tmp;
ppt[i].clear();
for(int j=;j < N;j++) if(i != j)
{
tmp.dis = dis(pt[i],pt[j]);
tmp.id = j;
ppt[i].push_back(tmp);
}
sort(ppt[i].begin(),ppt[i].end());
} int ans = ;
int save[];
for(int i=;i<N;i++)
{
for(int j=i+;j<N;j++)
{
//printf("now use:%d %d\n",i,j);
for(int k=;k<ppt[i].size();k++) if(ppt[i][k].id != j)
{
for(int h=k+;h<ppt[i].size() && ppt[i][k].dis == ppt[i][h].dis;h++) if(ppt[i][h].id != j)
{
if(dis(pt[j],pt[ppt[i][h].id]) == dis(pt[j],pt[ppt[i][k].id]) && dis(pt[j],pt[ppt[i][h].id]) == ppt[i][k].dis)
{
if(onPlane(pt[i],pt[j],pt[ppt[i][k].id],pt[ppt[i][h].id]) ) continue;
//int s = myhash(i,j,ppt[i][k].id,ppt[i][h].id);
//printf("%d %d %d %d\n",i,j,ppt[i][k].id,ppt[i][h].id);
vector <int> ve;
ve.push_back(i);
ve.push_back(j);
ve.push_back(ppt[i][k].id);
ve.push_back(ppt[i][h].id);
sort(ve.begin(),ve.end());
int s = myHash(ve[],ve[],ve[],ve[]);
if(st.find(s) == st.end())
{
st.insert(s);
//printf("%d %d %d %d\n",i,j,ppt[i][k].id,ppt[i][h].id);
//printf("%d\n",_onPlane(pt[i],pt[j],pt[ppt[i][k].id],pt[ppt[i][h].id]));
ans++;
} }
}
}
}
} printf("Case #%d: %d\n",++cas,ans);
}
}

ccpc-1008-HDU5839Special Tetrahedron-计算几何的更多相关文章

  1. HDU 5839 Special Tetrahedron 计算几何

    Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  2. hdu6731 Angle Beats(ccpc秦皇岛A,计算几何)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6731 题意: 给出$n$个点,有$q$次询问 每次询问给出一个点$b$,求这$n+1$个点,组成直角 ...

  3. hdu 6127 : Hard challenge (2017 多校第七场 1008)(计算几何)

    题目链接 题意:二维平面上有n个点(没有重叠,都不在原点,任意两点连线不过原点),每个点有一个权值,用一条过原点的直线把他们划分成两部分,使两部分的权值和的乘积最大.输出最大的乘积. 极角排序后,将原 ...

  4. (四面体)CCPC网络赛 HDU5839 Special Tetrahedron

    CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...

  5. 计算几何----判断空间点是否在一个四面体(tetrahedron)内部

    DESCRIPTION: 判断空间点 P(x, y, z)是否在一个四面体的内部? Let the tetrahedron have vertices V1 = (x1, y1, z1) V2 = ( ...

  6. HDU 5839 Special Tetrahedron (计算几何)

    Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  7. HDU 5733 tetrahedron(计算几何)

    题目链接 tetrahedron 题目大意 输入一个四面体求其内心,若不存在内心则输出"O O O O" 解题思路 其实这道题思路很简单,只要类推一下三角形内心公式就可以了. 至于 ...

  8. 【HDU 5839】Special Tetrahedron(计算几何)

    空间的200个点,求出至少四边相等,且其余两边必须不相邻的四面体的个数. 用map记录距离点i为d的点有几个,这样来优化暴力的四重循环. 别人的做法是枚举两点的中垂面上的点,再把到中点距离相等的点找出 ...

  9. 湖南程序设计竞赛赛题总结 XTU 1237 Magic Triangle(计算几何)

    这个月月初我们一行三人去湖南参加了ccpc湖南程序设计比赛,虽然路途遥远,六月的湘潭天气燥热,不过在一起的努力之下,拿到了一块铜牌,也算没空手而归啦.不过通过比赛,还是发现我们的差距,希望这几个月自己 ...

  10. 【赛后总结+部分题解】2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛

    赛后总结: T:今天状态一般,甚至有点疲惫.然后12点比赛开始,和队友开始看题,从最后往前面看,发现数学题公式看不懂.然后发现队友已经双开做1001和1006了,我看着1007有人A,开始做1007. ...

随机推荐

  1. Java Concurrency In Practice - Chapter 1 Introduction

    1.1. A (Very) Brief History of Concurrency motivating factors for multiple programs to execute simul ...

  2. 烂泥:虚拟化KVM安装与配置

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近打算把公司的服务器全部做成虚拟化,一是跟有效的利用了服务器,二也是对自己是一个学习的机会. KVM的安装与配置步骤如下: 1. 查看是否支持虚拟化 ...

  3. 初识zookeeper(一)之zookeeper的安装及配置

    1.简要介绍 zookeeper是一个分布式的应用程序协调服务,是Hadoop和Hbase的重要组件,是一个树型的目录服务,支持变更推送.除此还可以用作dubbo服务的注册中心. 2.安装 2.1 下 ...

  4. Ubuntu进阶学习,指令迅速查询,Bug迅速查询(Ctrl+F)

    There is some notes while I am learning Ubuntu Operate System! (Ask Ubuntu) 1-- Hard link : ln comma ...

  5. Mac OS X 中vim开启配色和git补全

    问题起源:mac 下自带的git 无法补全命令,配色方案不完善 Mac OS Yosemite 10.10.3 git version 2.3.2 (Apple Git-55) 处理结果:git命令可 ...

  6. Linux root 密码重置与用户管理

    ---forget root password restart your linux system press 'e' when start. press 'e' again then choose ...

  7. POJ 3481Double Queue Splay

    #include<stdio.h> #include<string.h> ; ],data[N],id[N],fa[N],size,root; void Rotate(int ...

  8. Android UI组件----ListView列表控件详解

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  9. 栈和队列的面试题Java实现【重要】

    栈和队列: 面试的时候,栈和队列经常会成对出现来考察.本文包含栈和队列的如下考试内容: (1)栈的创建 (2)队列的创建 (3)两个栈实现一个队列 (4)两个队列实现一个栈 (5)设计含最小函数min ...

  10. 数据结构Java实现05----栈:顺序栈和链式堆栈

    一.堆栈的基本概念: 堆栈(也简称作栈)是一种特殊的线性表,堆栈的数据元素以及数据元素间的逻辑关系和线性表完全相同,其差别是线性表允许在任意位置进行插入和删除操作,而堆栈只允许在固定一端进行插入和删除 ...