题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<list>
#define mem(x,y)memset(x,y,sizeof(x))
#define max(a,b)(a)>(b)?(a):(b)
#define min(a,b)(a)<(b)?(a):(b)
#define inf 0x1f1f1f1f
#define eps 1e-10
#define M 1000007
using namespace std;
const int maxn=1005;
struct node
{
int x,y;
}c1[35];
struct cyx
{
int x1,y1,x2,y2,x3,y3,x4,y4;
int area;
}c[100005];
struct qxw
{
int x,y;
};
qxw q[5];
int cmp(node a,node b)
{
if(a.y==b.y)
return a.x<b.x;
else
return a.y<b.y;
}
int cmp1(cyx a1,cyx b1)
{
return a1.area>b1.area;
}
int fun(cyx a,cyx b)
{
int i,j;
int maxx1=max(a.x1,a.x4);
int minx1=min(a.x1,a.x4);
int maxy1=max(a.y1,a.y4);
int miny1=min(a.y1,a.y4);
int s=0;
q[0].x=b.x1,q[0].y=b.y1;
q[1].x=b.x2,q[1].y=b.y2;
q[2].x=b.x3,q[2].y=b.y3;
q[3].x=b.x4,q[3].y=b.y4;
int f=0;
for(i=0;i<4;i++)
{
if(q[i].x>=minx1&&q[i].x<=maxx1&&q[i].y>=miny1&&q[i].y<=maxy1)
{
if((q[i].x==minx1&&q[i].y>=miny1&&q[i].y<=maxy1)||
(q[i].x==maxx1&&q[i].y>=miny1&&q[i].y<=maxy1)||
(q[i].y==miny1&&q[i].x>=minx1&&q[i].x<=maxx1)||
(q[i].y==maxy1&&q[i].x>=minx1&&q[i].x<=maxx1))
{
f=1;
break;
}
else
{
s++;
}
}
}
if(f)
{
return 0;
}
if(s==4)
{
return 2;
}
else if(s==1||s==2||s==3)
{
return 0;
}
else
{
return 1;
}
}
int main()
{
int i,j,k,l,flag,n,s,f;
while(~scanf("%d",&n))
{
flag=-1;
if(n==0)break;
for(i=0;i<n;i++)
scanf("%d %d",&c1[i].x,&c1[i].y);
sort(c1,c1+n,cmp);
f=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
for(int k=j+1;k<n;k++)
{
for(int k1=k+1;k1<n;k1++)
{
//printf("%d %d %d %d %d %d %d %d\n",c1[i].x,c1[i].y,c1[j].x,c1[j].y,c1[k].x,c1[k].y,c1[k1].x,c1[k1].y);
if(c1[i].y==c1[j].y&&c1[i].x==c1[k].x&&c1[k].y==c1[k1].y&&c1[k1].x==c1[j].x)
{
//printf("*\n");
c[f].x1=c1[i].x;
c[f].y1=c1[i].y;
c[f].x2=c1[j].x;
c[f].y2=c1[j].y;
c[f].x3=c1[k].x;
c[f].y3=c1[k].y;
c[f].x4=c1[k1].x;
c[f].y4=c1[k1].y;
c[f].area=(c1[j].x-c1[i].x)*(c1[k].y-c1[i].y);
f++;
}
}
}
}
}
sort(c,c+f,cmp1);
for(int i=0;i<f;i++)
{
for(int j=i+1;j<f;j++)
{
if(fun(c[i],c[j])==1)
{
s=c[i].area+c[j].area;
if(s>flag)
flag=s;
}
if(fun(c[i],c[j])==2)
{
s=max(c[i].area,c[j].area);
if(s>flag)
flag=s;
}
}
}
if(flag==-1)
printf("imp\n");
else
printf("%d\n",flag);
}
return 0;
}