计算几何水题。暴力搞

注意力全部都在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. linux下批量修改存有超大数据量IP文件中的IP内容以及去重排序

    作为一个linux的学徒,分享一下自己解决这个小问题的心得,在处理这个问题时使用了一个小技巧感觉很适用,个人发觉linux的终端真滴是非常强大,下面就详细地介绍这个问题以及解决办法吧 问题描述:由于要 ...

  2. 一. Linux 常用命令总结

    1. linux 基础命令 who, which, basename, dirname, echo, type, hash, whatis, makewhatis, man, info, help,  ...

  3. Uva-11374-Airport Express

    A - Airport Express Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Appoi ...

  4. linux 删除已输入的命令行

    ctrl + w —往前删除一个单词,光标放在最末尾ctrl + k —删除到末尾,光标放在最前面(可以使用ctrl+a) —————————————————————-华丽的分割线ctl + u 删除 ...

  5. 平摊分析 Amortized Analysis ------geeksforgeeks翻译

    当偶尔一切操作很花的时间很慢,而大多数操作的时间都很快的时候,平摊分析的方法就很很好用了.在平摊分析中,我们分析一串操作并且可以得到最坏情况下的平均时间复杂度.例如hash table, disjoi ...

  6. 读《深入理解Java虚拟机》有感——第二部分:虚拟机类加载机制

    一.类加载过程       执行时机:编译程序——>执行程序(JVM启动.程序运行),类加载发生在程序运行期间       各个阶段:分为加载阶段.连接阶段(验证.准备.解析).初始化.使用.卸 ...

  7. HDU 4568 Hunter 最短路+状压DP

    题意:给一个n*m的格子,格子中有一些数,如果是正整数则为到此格子的花费,如果为-1表示此格子不可到,现在给k个宝藏的地点(k<=13),求一个人从边界外一点进入整个棋盘,然后拿走所有能拿走的宝 ...

  8. POJ 1984 Navigation Nightmare

    并查集,给n个点和m条边,每条边有方向和长度,再给q个询问,第i个询问查询两个点之间在Ti时刻时的曼哈顿距离(能连通则输出曼哈顿距离,否则输出-1) 这题跟Corporative Network 有点 ...

  9. Tarjian算法求强联通分量

    如果两个顶点可以相互通达,则称两个顶点强连通(strongly connected).如果有向图G的每两个顶点都强连通,称G是一个强连通图.强连通图有向图的极大强连通子图,称为强连通分量(strong ...

  10. JS中的基本运动逻辑思想总结

    总结一下自己今天学习运动的基本思想:‘ [1]对于移动的div,使其在某一个位置停止将其封装成一个函数,仅仅改变speed的正负即可 涉及到问题包括: var time=null; function  ...