今天拍了一道很简单的计算几何凸包的题目POJ 2187 Beauty Contest;想涨涨自信滴呀~没想到wrong得我蛋蛋碎了一地。后来才发现啃爹的poj在g++编译环境下不能用 %lf 输出浮点数的答案 (在c++环境下可以~~~)
#define fi freopen("in.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
/*my_template*/
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(int i=s;i<n;++i)
#define _fr(i,n,s) for(int i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
#define _ni(x) (1<<(x))
#define _niL(x) (1LL<<(x))
#define _has(s,x) ((s&(_ni(x)))!=0)
#define _hasL(s,x) ((s&(_niL(x)))!=0LL)
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;
/*my_template*/
const int N = 100010;
struct Point{
double x,y;
Point(double _x=0,double _y=0){
x=_x,y=_y;
}
void read(){
scanf("%lf%lf",&x,&y);
}
}p[N],chs[N];
int n;
double multiply(Point op,Point sp ,Point ep){
return ((sp.x-op.x)*(ep.y-op.y)-(ep.x-op.x)*(sp.y-op.y));
}
double dist_2(Point p1,Point p2){
return ((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
double dist(Point p1,Point p2){
return sqrt(dist_2(p1,p2));
}
bool gramhap_cmp(Point a,Point b){
double k = multiply(p[0],a,b);
if (fabs(k)<_eps) return dist(a,p[0])<dist(p[0],b);
else if (k>0) return 1;
else return 0;
}
int graham(){
int mny = p[0].y ,idx = 0;
fr(i,1,n){
if (p[i].y < mny) mny = p[i].y,idx = i;
else if (p[i].y == mny &&p[i].x <p[idx].x) idx = i;
}
Point tmp = p[idx];
p[idx] = p[0];p[0] = tmp;
sort(p+1,p+n,gramhap_cmp);
chs[0] = p[n-1];
chs[1] = p[0];
int stop = 1,pos =1;
while(pos<=n-1){
double d = multiply(chs[stop],chs[stop-1],p[pos]);
if (d<=0) chs[++stop] = p[pos++];
else stop--;
}
return stop+1;
}
int main(){
#ifdef local
fi;
#endif
sfint(n);
fr(i,0,n){
p[i].read();
}
int chn = graham();
double ans = 0;
for (int i=0;i<chn;i++)
for (int j=i+1;j<chn;j++)
if (ans<dist_2(chs[i],chs[j]))
ans=dist_2(chs[i],chs[j]);
printf("%.0f\n",ans+0.003);
return 0;
}