55pts 样例没过,交上去有55pts
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
struct node{
int x,y;
}a[1005];
double g[1005][1005],dist[1005];
bool vis[1005];
double c(int x,int y,int xx,int yy){
return sqrt((xx-x)*(xx-x)*1.0+(yy-y)*(yy-y)*1.0);
}
int n,w,m;
int main(){
cin>>n>>w>>m;
for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
g[i][j]=c(a[i].x,a[i].y,a[j].x,a[j].y);
for(int i=1;i<=m;i++){
int xx,yy;
cin>>xx>>yy;
g[xx][yy]=g[yy][xx]=0;
}
memset(dist,0x3f,sizeof dist);
dist[1]=0;
for(int i=1;i<=n;i++){
int mid=999999999,id=0;
for(int j=1;j<=n;j++){
if(vis[j]==0 && dist[j]<mid){
mid=dist[j];
id=j;
}
}
vis[id]=1;
for(int j=1;j<=n;j++)
if(dist[j]>dist[id]+g[id][j] && g[id][j]<m)
dist[j]=dist[id]+g[id][j];
}
if(dist[n]==0x3f3f3f3f)cout<<"-1";
else cout<<int(dist[n]*1000);
return 0;
}
大佬救啊