diff --git a/HDOJ/3790_cnblogs.cpp b/HDOJ/3790_cnblogs.cpp new file mode 100644 index 0000000..6a9bb4f --- /dev/null +++ b/HDOJ/3790_cnblogs.cpp @@ -0,0 +1,144 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +//Constant Declaration +/*--------------------------*/ +//#define LL long long +#define LL __int64 +const int M=1100;//最多点数 +const int INF=1<<30; +const double EPS = 1e-11; +const double PI = acos(-1.0); +/*--------------------------*/ +// some essential funtion +/*----------------------------------*/ +void Swap(int &a,int &b){ int t=a;a=b;b=t; } +int Max(int a,int b){ return a>b?a:b; } +int Min(int a,int b){ return a d[min_num].l + g[min_num][i].l) + { + d[i].l = d[min_num].l + g[min_num][i].l; + d[i].p = d[min_num].p + g[min_num][i].p; + } + if (!used[i] && d[i].l == d[min_num].l + g[min_num][i].l && d[i].p > d[min_num].p + g[min_num][i].p)//这里的判断是关键 + { + d[i].p = d[min_num].p + g[min_num][i].p; + } + } + + } + return d[end].l; +} + + + + + +int main() +{ + //freopen("in.txt","r",stdin); + //freopen("out.txt","w",stdout); + //int t, case1 = 0; + //scanf("%d", &t); + int n, m; + int i, j; + while (scanf("%d%d", &n, &m), n + m) + { + init(n); + for (i = 0; i < m; i++) + { + int a, b, c, c1; + scanf("%d%d%d%d", &a, &b, &c, &c1); + if (g[a][b].l > c) + { + g[b][a].l = g[a][b].l = c; + g[b][a].p= g[a][b].p = c1; + }//此题为无向图 + if (g[a][b].l == c && g[b][a].p > c1)//这里的判断是关键 + { + g[b][a].p= g[a][b].p = c1; + } + + } + int star, end,ans; + scanf("%d%d", &star, &end); + ans = dijkstra(star, end, n); + printf("%d %d\n", ans, d[end].p); + } + + return 0; +}