求大佬验代码

P1744 采购特价商品

@[TheOrnateJade_ofSun](/space/show?uid=134876) spfa内部的wi没有变成double类型。 我只改了两个地方,一个是输出,一个数spfa内部。 ```cpp #include<bits/stdc++.h> #define G 200 using namespace std; int tot,head[G],vis[G],n,m,s,t; double dis[G]; struct node{ int st,end,nxt;double wi; }e[G]; struct mode{ int x,y; }p[G]; void add(int u,int v,double w){ tot++; e[tot].st=u; e[tot].end=v; e[tot].wi=w; e[tot].nxt=head[u]; head[u]=tot; } double clz(int x,int y){ return sqrt((double)(p[x].x-p[y].x)*(p[x].x-p[y].x)+(p[x].y-p[y].y)*(p[x].y-p[y].y)); } void spfa(){ queue<int> q; memset(vis,0,sizeof(vis)); for(int i=1;i<=n;i++) dis[i]=INT_MAX/2; q.push(s); vis[s]=1;dis[s]=0; while(!q.empty()){ int u=q.front() ;q.pop() ; vis[u]=0; for(int i=head[u];i;i=e[i].nxt){ int v=e[i].end; double w=e[i].wi; if(dis[v]>dis[u]+w){ dis[v]=dis[u]+w; if(!vis[v]){ vis[v]=1; q.push(v); } } } } } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>p[i].x>>p[i].y; } cin>>m; for(int a,b,i=1;i<=m;i++){ cin>>a>>b; add(a,b,clz(a,b)); add(b,a,clz(a,b)); } cin>>s>>t; spfa(); printf("%.2lf\n", dis[t]); return 0; } ```
by mulberror @ 2019-03-26 01:21:09


@[Chhokmah](/space/show?uid=35567) 谢谢谢谢谢谢谢谢奆佬
by Grussg @ 2019-03-26 18:47:59


@[TheOrnateJade_ofSun](/space/show?uid=134876) 不要膜我这种蒟蒻qwq
by mulberror @ 2019-03-26 18:55:58


|