题解:#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
const int N = 1500+10;
int n,m;
struct Point{
int x,y;
Point(){}
Point(int aa,int bb):x(aa),y(bb){}
void print(){
printf("%d %d\n",x,y);
}
}point[N];
Point operator + (Point a,Point b){return Point(a.x+b.x,a.y+b.y);}
struct Line{
int p[2];Point cent;long long len;
}lines[N*N];int ln;
bool operator < (Point a,Point b){return a.x==b.x?a.y<b.y:a.x < b.x;}
bool operator == (Point a,Point b){return a.x==b.x&&a.y==b.y;}
bool dcmp(double a,double b){return fabs(a-b) < 1e-9;}
bool operator < (const Line &a,const Line &b){
if(!(a.cent==b.cent))return a.cent < b.cent;
return a.len < b.len;
}
bool operator == (Line &a,Line &b){return a.len==b.len && a.cent == b.cent;}
Point operator - (Point a,Point b){return Point(a.x-b.x,a.y-b.y);}
double cross(Point a,Point b){return (double)a.x*b.y-(double)a.y*b.x;}
double dis(Point a,Point b){return hypot(a.x-b.x,a.y-b.y);}
int scan(){int i=0;scanf("%d",&i);return i;}
int main(){
//freopen("input.txt","r",stdin);
int i,j,a,b,c;
n = scan();
for(i=1;i<=n;i++){
a = scan();b = scan();
point[i] = Point(a,b);
}
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++){
ln++;
lines[ln].p[0] = i;lines[ln].p[1] = j;
lines[ln].cent = point[i] + point[j];
//cout << lines[ln].cent.x << ' '<<lines[ln].cent.y<<endl;
long long tmp[2];
tmp[0] = point[i].x-point[j].x;
tmp[1] = point[i].y-point[j].y;
//lines[ln].len = hypot(point[i].x-point[j].x,point[i].y-point[j].y);
lines[ln].len = tmp[0]*tmp[0]+tmp[1]*tmp[1];;
}
sort(lines+1,lines+1+ln);
double ans = 0;
for(i=1;i<ln;i++)
for(j=i+1;j<=ln;j++)
if(lines[i]==lines[j]){
//printf("%f\n",lines[i].len);
double tmp[2];
a = lines[i].p[0];b = lines[i].p[1];
c = lines[j].p[0];
tmp[0] = cross(point[a]-point[c],point[b]-point[c]);
if(tmp[0]<0)tmp[0]=-tmp[0];
if(tmp[0] > ans){
ans = tmp[0];
}
}else break;
printf("%.0f\n",ans+1e-9);
return 0;
}
评论