1 条题解
-
1
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,m; ll res; struct Vector{ int x,y; Vector(){} Vector(int X,int Y){x=X,y=Y;} friend Vector operator +(const Vector &u,const Vector &v){return Vector(u.x+v.x,u.y+v.y);} friend Vector operator -(const Vector &u,const Vector &v){return Vector(u.x-v.x,u.y-v.y);} friend ll operator &(const Vector &u,const Vector &v){return 1ll*u.x*v.y-1ll*u.y*v.x;}//cross times friend ll operator |(const Vector &u,const Vector &v){return 1ll*u.x*v.x+1ll*u.y*v.y;}//point times ll operator ~()const{return 1ll*x*x+1ll*y*y;}//the modulo of a vector void read(){scanf("%d%d",&x,&y);} void print(){printf("(%d,%d)",x,y);} }p[1510]; typedef Vector Point; struct Line{ Point x,y; Vector z; Line(){} Line(Point X,Point Y){x=X,y=Y,z=Y-X;} friend bool operator <(const Line &u,const Line &v){ if(u.z&v.z)return (u.z&v.z)<0; if(~u.z!=~v.z)return ~u.z<~v.z; if((u.x-v.x)|v.z)return ((u.x-v.x)|v.z)<0; return ((u.x-v.x)&v.z)<0; } friend bool operator ==(const Line &u,const Line &v){ if(u.z&v.z)return false; if(~u.z!=~v.z)return false; if((u.x-v.x)|v.z)return false; return true; } }l[2250100]; typedef Line Segment; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)p[i].read(); for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(p[i].y<p[j].y||(p[i].y==p[j].y&&p[i].x<p[j].x))l[++m]=Segment(p[i],p[j]); sort(l+1,l+m+1); for(int i=1,j=1;i<=m;i=j){ while(j<=m&&l[i]==l[j])j++; res=max(res,abs(l[i].z&(l[i].x-l[j-1].x))); } printf("%lld\n",res); return 0; }
- 1
信息
- ID
- 2338
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 24
- 已通过
- 6
- 上传者