RT,代码31行的num+1改为++num会导致测试点#2,#8,#10 WA
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
const int maxn = 1e3+5;
int x[maxn],y[maxn],vis[10];
double dis[10][10],r[10];
double ans;
int xx,yy,xxx,yyy,sq,n;
void Init(){
cin>>n;
cin>>xx>>yy>>xxx>>yyy;
sq = abs(xx-xxx)*abs(yy-yyy);
for(int i = 1;i<=n;i++)
cin>>x[i]>>y[i];
for(int i = 1;i<=n;i++)
for(int j=i+1;j<=n;j++)
dis[i][j] = dis[j][i] =sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
void dfs(int num,double sum){
if(num == n+1 ) ans = max(sum,ans);
for(int i = 1;i<=n;i++)
if(!vis[i]){
r[i] = min(min(abs(x[i]-xx),abs(x[i]-xxx)), min(abs(y[i]-yy),abs(y[i]-yyy)));//
for(int j = 1;j<=n;j++)
if(vis[j]) r[i] = min(r[i],dis[i][j]-r[j]);//
vis[i] = true;
if(r[i]<=0) r[i] = 0;
dfs(num+1,sum+M_PI*r[i]*r[i]);//++num会错:100pts->70pts
vis[i] = false;
}
return ;
}
signed main(){
Init();
dfs(1,0.00);
printf("%.0f",sq-ans);
}
其中#2的测试点:
in:
3
-98 5 30 30
-42 11
-51 17
-11 22
out:
2547
使用++num:
2748