HDU 5206 Four Inages Strategy 水题

时间:2023-03-09 17:16:07
HDU 5206 Four Inages Strategy 水题

题目链接:

hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5206

bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=577&pid=1001

题解:

先判四点是否共面,然后再判断一下四条邻边相等并且两条对角线相等就可以了。

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; const int maxn=+;
typedef long long LL; struct Point {
LL x,y,z;
Point(LL x,LL y,LL z):x(x),y(y),z(z){}
Point(){};
friend Point operator - (const Point& p1,const Point& p2){
return Point(p1.x-p2.x,p1.y-p2.y,p1.z-p2.z);
}
} pt[]; typedef Point Vector; Vector cross(const Vector& v1,const Vector& v2){
return Vector(v1.y*v2.z-v1.z*v2.y,v2.x*v1.z-v1.x*v2.z,v1.x*v2.y-v1.y*v2.x);
} LL dis(int i,int j) {
Point pt1=pt[i];
Point pt2=pt[j];
return (pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y)+(pt1.z-pt2.z)*(pt1.z-pt2.z);
} bool judge(){
Vector v1=pt[]-pt[];
Vector v2=pt[]-pt[];
Vector v3=pt[]-pt[];
Vector cr1=cross(v1,v2);
Vector cr2=cross(v2,v3);
Vector ret=cross(cr1,cr2);
if(!ret.x&&!ret.y&&!ret.z) return true;
return false;
} int main() {
int tc,kase=;
scanf("%d",&tc);
while(tc--) {
for(int i=; i<; i++) scanf("%lld%lld%lld",&pt[i].x,&pt[i].y,&pt[i].z);
int flag=;
if(judge()) {
for(int i=; i<; i++) {
for(int j=; j<; j++) {
if(j!=i) {
for(int k=; k<; k++) {
if(k!=j&&k!=i) {
for(int l=; l<; l++) {
if(l!=i&&l!=j&&l!=k) {
if(dis(i,j)==dis(j,k)&&dis(j,k)==dis(k,l)&&dis(k,l)==dis(l,i)&&dis(i,k)==dis(j,l)) {
flag=;
}
}
}
}
}
}
}
}
}
printf("Case #%d: ",++kase);
if(flag) {
puts("Yes");
} else {
puts("No");
}
}
return ;
}
/*
1 0 0 0 1 0 0 -1 0 0 0 1
1 0 0 0 1 0 0 -1 0 -1 0 0
*/