Created
February 9, 2011 13:11
-
-
Save kitayuta/818443 to your computer and use it in GitHub Desktop.
I died. (AOJ 0518)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cstdio> | |
#include<vector> | |
#include<algorithm> | |
#include<set> | |
#define men(d) (((d.vx*d.vx)+(d.vy*d.vy))/2) | |
using namespace std; | |
struct Data{ | |
short vx,vy,cx,cy; | |
Data(short a,short b,short c,short d){ | |
vx=a; | |
vy=b; | |
cx=c; | |
cy=d; | |
} | |
Data(){} | |
}; | |
inline bool operator<(const Data &a,const Data &b){ | |
if(a.vx<b.vx)return true; | |
if(a.vx==b.vx&&a.vy<b.vy)return true; | |
if(a.vx==b.vx&a.vy==b.vy&&a.cx<b.cx)return true; | |
if(a.vx==b.vx&&a.vy==b.vy&&a.cx==b.cx&&a.cy<b.cy)return true; | |
return false; | |
} | |
inline bool operator==(const Data &a,const Data &b){ | |
return a.vx==b.vx&&a.vy==b.vy&&a.cx==b.cx&&a.cy==b.cy; | |
} | |
int main(){ | |
int n; | |
for(;;){ | |
scanf("%d",&n); | |
if(n==0)break; | |
vector<pair<int,int> > ins(n); | |
for(int i=0;i<n;i++){ | |
int x,y; | |
scanf("%d%d",&x,&y); | |
ins[i]=make_pair(x,y); | |
} | |
vector<Data> high,mid,low; | |
for(int i=0;i<n;i++){ | |
for(int j=i+1;j<n;j++){ | |
int tx=ins[i].first-ins[j].first,ty=ins[i].second-ins[j].second; | |
Data d; | |
if(tx>=0){ | |
d.vx=tx; | |
d.vy=ty; | |
}else{ | |
d.vx=-tx; | |
d.vy=-ty; | |
} | |
d.cx=(ins[i].first+ins[j].first)/2; | |
d.cy=(ins[i].second+ins[j].second)/2; | |
if(d.vy==0)mid.push_back(d); | |
else if(d.vy>0)high.push_back(d); | |
else low.push_back(d); | |
} | |
} | |
sort(&high[0],&high[0]+high.size()); | |
sort(&mid[0],&mid[0]+mid.size()); | |
sort(&low[0],&low[0]+low.size()); | |
int ma=0; | |
for(int i=0;i<mid.size();i++){ | |
if(binary_search(high.begin(),high.end(),Data(0,mid[i].vx,mid[i].cx,mid[i].cy))||binary_search(low.begin(),low.end(),Data(0,-mid[i].vx,mid[i].cx,mid[i].cy)))ma=max(ma,men(mid[i])); | |
} | |
for(int i=0;i<high.size();i++){ | |
if(binary_search(low.begin(),low.end(),Data(high[i].vy,-high[i].vx,high[i].cx,high[i].cy)))ma=max(ma,men(high[i])); | |
} | |
printf("%d\n",ma); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment