void spfa()
{
memset(dist,
0x3f,
sizeof(dist));
dist[
1]=
0;
queue<int> que;
que.push(
1);
inque[
1]=
true;
while (!que.empty())
{
int now=que.front();
que.pop();
inque[now]=
false;
for (e(now->p))
if (dist[now]+e.length<dist[p])
{
dist[p]=dist[now]+e.length;
if (!inque[p])
{
inque[p]=
true;
que.push(p);
}
}
}
}