记录编号 42507 评测结果 AAAAAAAAAA
题目名称 [NOIP 2010冲刺六]油滴扩展 最终得分 100
用户昵称 GravatarTruth.Cirno 是否通过 通过
代码语言 C++ 运行时间 0.003 s
提交时间 2012-09-25 22:25:01 内存使用 0.29 MiB
显示代码纯文本
#include <cstdio>
#include <cmath>
//#include <memory.h>
using namespace std;

const double PI=3.1415926;

int n,rec[10];
double a1,b1,a2,b2,ao[10],bo[10],r[10],maxsqu;
bool used[10];

void swapdou(double& a,double& b)
{
	double temp;
	temp=a;
	a=b;
	b=temp;
}

double mtzdou(double a)
{
	if (a<0)
		return(0);
	return(a);
}

double absdou(double a)
{
	if(a<0)
		return(-a);
	return(a);
}

double mindou(double a,double b)
{
	if (a>b)
		return(b);
	return(a);
}

double maxdou(double a,double b)
{
	if (a<b)
		return(b);
	return(a);
}

void work(void)
{
	int i,j,pi,pj;
	double rt,squ=0;
//	memset(r,0,sizeof(r));
	for (i=1;i<=n;i++)
	{
		pi=rec[i];
		rt=mindou(absdou(ao[pi]-a1),absdou(bo[pi]-b1));
		rt=mindou(rt,absdou(a2-ao[pi]));
		rt=mindou(rt,absdou(b2-bo[pi]));
		for (j=1;/*j<=n*/j<i;j++)
		{
//			if (j==i)
//				continue;
			pj=rec[j];
			rt=mindou(rt,mtzdou(sqrt((ao[pj]-ao[pi])*(ao[pj]-ao[pi])+(bo[pj]-bo[pi])*(bo[pj]-bo[pi]))-r[pj]));
		}
		r[pi]=rt;
		squ+=rt*rt*PI;
	}
	maxsqu=maxdou(maxsqu,squ);
}

void dfs(int deep)
{
	if (deep>n)
	{
		work();
		return;
	}
	int i;
	for (i=1;i<=n;i++)
		if (!used[i])
		{
			used[i]=true;
			rec[deep]=i;
			dfs(deep+1);
//			rec[deep]=0;
			used[i]=false;
		}
}

int main(void)
{
	freopen("oilbox.in","r",stdin);
	freopen("oilbox.out","w",stdout);
	int i;
	scanf("%d",&n);
	scanf("%lf%lf%lf%lf",&a1,&b1,&a2,&b2);
	if (a2>a1)
		swapdou(a1,a2);
	if (b2>b1)
		swapdou(b1,b2);
	for (i=1;i<=n;i++)
		scanf("%lf%lf",&ao[i],&bo[i]);
	dfs(1);
	printf("%.0lf\n",(a2-a1)*(b2-b1)-maxsqu);
	return(0);
}