标签:back efi color return 最短路 bsp next include vector
syzoj.com 最短路径问题 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> using namespace std; #define maxn 10001 vector<int>a[maxn],b[maxn]; queue<int>bfs; int dis[maxn]; inline int read(){ int num=0,f=1; char c=getchar(); while(!isdigit(c)){if(c==‘-‘) f=-1; c=getchar();} while(isdigit(c)){num=(num<<1)+(num<<3)+(c^48); c=getchar();} return num*f; } int n,m; inline int in(){ n=read(); m=read(); for(int i=1;i<=m;i++){ int u,v,c; u=read(); v=read(); c=read(); a[u].push_back(v); b[u].push_back(c); } } inline int work(){ memset(dis,127,sizeof(dis)); dis[1]=0; bfs.push(1); while(!bfs.empty()){ int city=bfs.front(); bfs.pop(); int num=a[city].size(); for(int i=0;i<num;i++){ int next=a[city][i]; int next_c=b[city][i]; dis[next]=min(dis[next],dis[city]+next_c); bfs.push(next); } } } inline int out(){ cout<<dis[n]; } int main(){ in(); work(); out(); }
标签:back efi color return 最短路 bsp next include vector
原文地址:http://www.cnblogs.com/79707536wc/p/7617232.html