addedge写了两个一样的
by nflsjxc @ 2018-07-15 16:18:50
@[Chloristendika](/space/show?uid=76527)
by nflsjxc @ 2018-07-15 16:21:17
```cpp
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <cctype>
#include <queue>
#include <deque>
#include <cmath>
#include <map>
#define INF (9999999.000000)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define REP(i, x, y) for(int i = (int)x; i <= (int)y; i ++)
#define FOR(i, x, y) for(int i = (int)x; i < (int)y; i ++)
#define PER(i, x, y) for(int i = (int)x; i >= (int)y; i --)
using namespace std;
const int N = 110, M = 1000 + 10;
int head[N], cnt = 0, cro[N][2], s, t;
void input(int &t){
int n = 0, m = 1; char ch = getchar();
while(ch < '0' || ch > '9'){ if(ch == '-') m = -1; ch = getchar(); }
while(ch >= '0' && ch <= '9'){ n = (n << 3) + (n << 1) + ch - '0'; ch = getchar(); }
t = n * m; return;
}
struct Edge{
int u, v, _next;
double w;
}G[M << 1];
double dist(int a,int b){
return (sqrt(pow(double(cro[a][0]-cro[b][0]),2)+pow(double(cro[a][1]-cro[b][1]),2)));
}
void addedge(int u,int v,double w){
G[++cnt].u = u; G[cnt].v = v; G[cnt].w = w; G[cnt]._next = head[u]; head[u] = cnt;
}
double dis[N];
bool vis[N];
queue <int> que;
int n, m, t1, t2;
int main(){
memset(vis, 0, sizeof(vis));
memset(dis, INF, sizeof(dis));
input(n);
REP(i, 1, n){
input(t1), input(t2);
cro[i][0] = t1, cro[i][1] = t2;
}
input(m);
REP(i, 1, m){
input(t1), input(t2);
addedge(t1, t2, dist(t1,t2));
addedge(t2, t1, dist(t1,t2));
}
input(s), input(t);
dis[s] = 0.00000, vis[s] = 1;
que.push(s);
while(! que.empty() ){
int u = que.front(); que.pop(), vis[u] = 0;
for(int i = head[u]; i ; i = G[i]._next){
int v = G[i].v;
if(dis[u] + G[i].w < dis[v]){
dis[v] = dis[u] + G[i].w;
if(! vis[v]) vis[v] = 1, que.push(v);
}
}
}
printf("%.2lf", dis[t]);
return 0;
}
```
by nflsjxc @ 2018-07-15 16:22:40
这样就ac了
by nflsjxc @ 2018-07-15 16:22:56
@[nflsjxc](/space/show?uid=19163) 谢谢谢谢,(其实我记得我检查过这里了~~我眼花了~~)
by Chloris @ 2018-07-15 16:43:32