计几题TLE我就很不李姐
#include <bits/stdc++.h>//?
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define mem(arr,val) memset((arr),(val),(sizeof(arr)))
#define INT vector<int>
using namespace std;
const double eps = 1e-8;
const int INF = 0x3f3f3f;
inline int sgn(int x) {return !x?0:(x<0?-1:1);}
struct Point
{
int x,y;
Point(){}
Point(int x,int y):x(x),y(y){}
Point operator+(const Point p) {return Point(x+p.x,y+p.y);}
Point operator-(const Point p) {return Point(x-p.x,y-p.y);}
};
typedef Point Vector;
inline double Distance(Point A,Point B) {return hypot(A.x-B.x,A.y-B.y);}
inline int Dot(Vector A,Vector B) {return A.x*B.x+A.y*B.y;}
inline int Cross(Vector A,Vector B) {return A.x*B.y-A.y*B.x;}
inline double Len(Vector A) {return sqrt(Dot(A,A));}
inline double Angle(Vector A,Vector B) {return acos(Dot(A,B)/Len(A)/Len(B));}
inline bool Parallel(Vector A,Vector B) {return !Cross(A,B);}
inline bool Cross_segment(Point a,Point b,Point c,Point d)
{
int c1 = Cross(b-a,c-a),c2 = Cross(b-a,d-a);
int d1 = Cross(d-c,a-c),d2 = Cross(d-c,b-c);
return sgn(c1)*sgn(c2) <= 0 && sgn(d1)*sgn(d2) <= 0;
}
int main(int argc,char *argv[])
{
// freopen("sb.txt","r",stdin);
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
int T,i = 0;cin>>T;
while(T--)
{
again:
cout<<"Case "<<++i<<":";
Point A,B,C,D;
cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>D.x>>D.y;
int ab = Distance(A,B),ac = Distance(A,C),ad = Distance(A,D);
int cd = Distance(C,D),bd = Distance(B,D),bc = Distance(B,C);
int ABCD = 0,ACBD = 0,ADBC = 0;
if(Cross_segment(A,B,C,D)) ABCD = 1;
if(Cross_segment(A,C,B,D)) ACBD = 1;
if(Cross_segment(A,D,B,C)) ADBC = 1;
if((ABCD && ac == bd && ad == bc) //平行四边形
|| (ACBD && ab == cd && ad == bc)
|| (ADBC && ab == cd && ac == bd))
{
if(ab == cd && ac == bd && ad == bc) //矩形
{
if((ABCD && !Dot(B-A,D-C)) || (ACBD && !Dot(C-A,D-B)) || (ADBC && !Dot(D-A,C-B)))
{cout<<"Square"<<endl;goto again;} //正方形
else {cout<<"Rectangle"<<endl;goto again;}
}
else
{
if((ABCD && !Dot(B-A,D-C)) || (ACBD && !Dot(C-A,D-B)) || (ADBC && !Dot(D-A,C-B)))
{cout<<"Rhombus"<<endl;goto again;}
else {cout<<"Parallelogram"<<endl;goto again;}
}
}
else
{
if(Parallel(B-A,D-C) || Parallel(C-A,D-B) || Parallel(D-A,C-B))
{cout<<"Trapezium"<<endl;goto again;}
else {cout<<"Ordinary Quadrilateral"<<endl;goto again;}
}
}
return 0;
}