ccpc-1008-HDU5839Special Tetrahedron-计算几何
计算几何水题。暴力搞
注意力全部都在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-计算几何的更多相关文章
- HDU 5839 Special Tetrahedron 计算几何
Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- hdu6731 Angle Beats(ccpc秦皇岛A,计算几何)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6731 题意: 给出$n$个点,有$q$次询问 每次询问给出一个点$b$,求这$n+1$个点,组成直角 ...
- hdu 6127 : Hard challenge (2017 多校第七场 1008)(计算几何)
题目链接 题意:二维平面上有n个点(没有重叠,都不在原点,任意两点连线不过原点),每个点有一个权值,用一条过原点的直线把他们划分成两部分,使两部分的权值和的乘积最大.输出最大的乘积. 极角排序后,将原 ...
- (四面体)CCPC网络赛 HDU5839 Special Tetrahedron
CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...
- 计算几何----判断空间点是否在一个四面体(tetrahedron)内部
DESCRIPTION: 判断空间点 P(x, y, z)是否在一个四面体的内部? Let the tetrahedron have vertices V1 = (x1, y1, z1) V2 = ( ...
- HDU 5839 Special Tetrahedron (计算几何)
Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- HDU 5733 tetrahedron(计算几何)
题目链接 tetrahedron 题目大意 输入一个四面体求其内心,若不存在内心则输出"O O O O" 解题思路 其实这道题思路很简单,只要类推一下三角形内心公式就可以了. 至于 ...
- 【HDU 5839】Special Tetrahedron(计算几何)
空间的200个点,求出至少四边相等,且其余两边必须不相邻的四面体的个数. 用map记录距离点i为d的点有几个,这样来优化暴力的四重循环. 别人的做法是枚举两点的中垂面上的点,再把到中点距离相等的点找出 ...
- 湖南程序设计竞赛赛题总结 XTU 1237 Magic Triangle(计算几何)
这个月月初我们一行三人去湖南参加了ccpc湖南程序设计比赛,虽然路途遥远,六月的湘潭天气燥热,不过在一起的努力之下,拿到了一块铜牌,也算没空手而归啦.不过通过比赛,还是发现我们的差距,希望这几个月自己 ...
- 【赛后总结+部分题解】2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛
赛后总结: T:今天状态一般,甚至有点疲惫.然后12点比赛开始,和队友开始看题,从最后往前面看,发现数学题公式看不懂.然后发现队友已经双开做1001和1006了,我看着1007有人A,开始做1007. ...
随机推荐
- 记录JVM垃圾回收算法
垃圾回收算法可以分为三类,都基于标记-清除(复制)算法: Serial算法(单线程) 并行算法 并发算法 JVM会根据机器的硬件配置对每个内存代选择适合的回收算法,比如,如果机器多于1个核,会对年轻代 ...
- grep, sed, awk
这几个工具是shell中非常好用的文本流处理工具,可以进行查找,编辑或者分析等工作,它们都支持正则表达式,也支持使用shell内置的变量 grep grep是一个字符串比较工具,用于从文件中提取满足条 ...
- javascript特效实现(4)——当前时间和倒计时效果
这个效果的实现关键是对Date对象和setTimeout的使用. 一共有三个例子,HTML结构如下,就不添加CSS样式了. <body> 当前时间:<p id="p1&qu ...
- 升级了win10后开启wifi热点出现iphone&macbook连接断线的问题(win7也一样)
升级了win10后开启wifi热点出现iphone&macbook连接 不间断 断线的问题 文后附上开启虚拟wifi的办法 百度参考了别人也出现这种问题,解决办法是修改信道,默认信道是11,修 ...
- A daemon process class in python
In everbright task schedule project, we need some daemon process to do certain work, here is a examp ...
- Android之TelephonyManager类的方法详解
TelephonyManager类主要提供了一系列用于访问与手机通讯相关的状态和信息的get方法.其中包括手机SIM的状态和信息.电信网络的状态及手机用户的信息.在应用程序中可以使用这些get方法获取 ...
- sudo: unable to resolve host xxx解决办法
问题: root@wiki:~# sudo lsb_release -a sudo: unable to resolve host wiki No LSB modules are available. ...
- NOI2016 山西省省选 第二题序列
给出一个n(n<=10^18)然后把n拆成若干个数之和(3=1+2=2+1 是两种情况) 然后把这写数字当作斐波那契数列的下标相乘再相加 例如: 3=1+1+1=1+2=2+1=3 所以结果就是 ...
- ZBrush中的笔刷该怎样制作
ZBrush给用户提供了许多的常用笔刷,我们可以使用这些笔刷自由地发挥创意.为了让雕刻速度更快,模型刻画更细致我们常常也会创建自定义笔刷,本文教您在ZBrush中制作笔刷. 查看更多内容请直接前往:h ...
- 合工大 OJ 1332 蛇形阵
Description 蛇形针回字阵: 如3*3: 回字阵: 7 6 5 8 1 4 9 2 3 Input 多组数据: 每一行一个正整数n(n为奇数,<26),代表n*n矩阵. Output ...