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. ...
随机推荐
- MySQL 强制操作以及order by 使用
我们以MySQL中常用的hint来进行详细的解析,如果你是经常使用Oracle的朋友可能知道,Oracle的hincvt功能种类很多,对于优化sql语句提供了很多方法. 同样,在MySQL里,也有类似 ...
- windows下使用tomcat部署网站
一.配置过程: 1. 配置java环境(之前已装过,跳过此步骤) 2. 下载tomcat (1)找到支持此java版本的tomcat版本: (2)下载与当前系统对应的安装文件 http://tom ...
- 最短路径之迪杰斯特拉(Dijkstra)算法
迪杰斯特拉(Dijkstra)算法主要是针对没有负值的有向图,求解其中的单一起点到其他顶点的最短路径算法.本文主要总结迪杰斯特拉(Dijkstra)算法的原理和算法流程,最后通过程序实现在一个带权值的 ...
- 烂泥:centos安装LVM方式
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近开始打算学习有关LVM逻辑卷的知识,由于以前没有接触过,看了很多有关这方面的视频.但是一直不深入.今天就先不管了,先把centos系统安装在LVM上 ...
- java Timer(定时调用、实现固定时间执行)
最近需要用到定时调用的功能.可以通过java的Timer类来进行定时调用,下面是有关Timer的一些相关知识. 其实就Timer来讲就是一个调度器,而TimerTask呢只是一个实现了run方法的一个 ...
- linux下mysql安装、目录结构、配置
1.准备安装程序(官方网站下载) 服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm 客户端:MySQL-client-community-5.1.4 ...
- NOIP2008普及组 题解 -SilverN
T1 ISBN号码 题目描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字.1位识别码和3位分隔符, 其规定格式如“x-xxx-xxxxx-x”,其中符号“-”就是分隔符( ...
- selenium如何分别启动IE、firefox、chrome浏览器
1.火狐浏览器 /* * 初始化火狐浏览器 * */ public static WebDriver initFireFox(WebDriver dr) { String key = "we ...
- codeforces 487B B. Strip(RMQ+二分+dp)
题目链接: B. Strip time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- android studio 中的编码问题
在 Android studio 中直接创建项目和导入其他项目都会有一个文件编码设定的问题,在 android studio (version 1.2.0)中设置文件的编码,只需要两步: 1.打开Se ...