syzoj.com 最短路径问题
#include#include #include #include #include #include using namespace std;vector a[100001],b[100001];queue bfs;int dis[100001];int main(){ memset(dis,127,sizeof(dis)); dis[1]=0; int n,m; cin>>n>>m; int u,v,c; for(int i=1;i<=m;i++){ cin>>u>>v>>c; a[u].push_back(v); b[u].push_back(c); } bfs.push(1); while(!bfs.empty()){ int city=bfs.front(); bfs.pop(); int num=a[city].size(); for(int i=0;i dis[city]+next_c){ dis[next]=dis[city]+next_c; bfs.push(next); } } } cout<