## 油滴拓展 ##
阿新 • • 發佈:2018-12-10
油滴拓展
#include<bits/stdc++.h>
using namespace std;
int c[10];
int m,n,xs,xe,ys,ye;
double sum;
bool b[10];
int a[2000][20];
int x[10];
int y[10];
double dis(int i,int j)
{
return(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
}
int dfs(int xx)
{
int i;
if (xx==n)
{
m++;
for (i=1;i<=n;i++) a[m][i]=c[i];
return 0;
}
for (i=1;i<=n;i++) if (b[i])
{
b[i]=false;
c[xx+1]=i;
dfs(xx+1);
b[i]=true;
}
}
double min(double t1,double t2)
{
if (t1>t2) return(t2); else return(t1);
}
double summ(int t)
{
int i,j;
double r[10];
double s;
for (i=1;i<=n;i++) r[i]=-1.0;
for (i=1;i<=n;i++)
{
s=INT_MAX;
s=min(s,abs(x[a[t][i]]-xs));
s=min(s,abs(x[a[t][i]]-xe));
s=min(s,abs(y[a[t][i]]-ys));
s=min(s,abs(y[a[t][i]]-ye));
for (j=1 ;j<=n;j++)
{
if (dis(a[t][i],j)<r[j])
{
s=0;
break;
}
if ((r[j]!=-1)&(a[t][i]!=j)) s=min(s,(dis(a[t][i],j)-r[j]));
}
r[i]=s;
}
s=0;
for (i=1;i<=n;i++) if (r[a[t][i]]!=-1) s=s+r[a[t][i]]*r[a[t][i]]*M_PI ;
return(s);
}
int main()
{
int i,j;
cin>>n;
m=0;
for (i=1;i<=n;i++) b[i]=true;
dfs(0);
cin>>xs>>ys>>xe>>ye;
for (i=1;i<=n;i++) cin>>x[i]>>y[i];
sum=-1;
for (i=1;i<=m;i++)
{
if (summ(i)>sum) sum=summ(i);
}
sum=(double)abs(xs-xe)*abs(ys-ye)-sum;
cout<<(int)(sum+0.5);
}