void spfa(){int index,i;while(!Q.empty()){index=Q.front();Q.pop();for(i=0;i<edge[index].size();i++){if(dist[edge[index][i].id]<dist[index]+edge[index][i].fa){ dist[edge[index][i].id]=dist[index]+edge[index][i].fa;//if(index!=mm)//mark[index]=0;flag[edge[index][i].id]++;if(flag[edge[index][i].id]>...