传送门
表示最小生成树很可做
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define ch cheap
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
struct node{
int x,y,w;
}e[2000005];
int x[1000005],y[1000005];
int f[1000005];
int find(int i) {return f[i]==i?i:f[i]=find(f[i]);}
bool cmp(node x,node y) {return x.w<y.w;}
int main()
{
freopen("pupil.in","r",stdin);
freopen("pupil.out","w",stdout);
int n=read(),a=read(),b=read();
for(int i=1;i<=n;i++) x[i]=read(),y[i]=read();
int m=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if(i==j) continue;
e[++m].x=i;e[m].y=j;
e[m].w=(abs(x[i]-x[j])+abs(y[i]-y[j]))*b;
}
for(int i=1;i<=n;i++)
e[++m].x=0,e[m].y=i,e[m].w=a;
sort(e+1,e+1+m,cmp);
for(int i=0;i<=n;i++) f[i]=i;
int ans=0;
for(int i=1;i<=m;i++)
{
if(find(e[i].x)==find(e[i].y)) continue;
f[find(e[i].x)]=find(e[i].y);
ans+=e[i].w;
}
cout<<ans;
return 0;
}