UVAOJ 10048 - Audiophobia Floyd

Posted Flowersea

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVAOJ 10048 - Audiophobia Floyd相关的知识,希望对你有一定的参考价值。

链接:

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=989

题意&题解:

紫书P365

代码:

31     int c, s, q;
32     int d[MAXN][MAXN];
33 
34     int main() {
35         ios::sync_with_stdio(false), cin.tie(0);
36         int cas = 1;
37         while (cin >> c >> s >> q, c) {
38             memset(d, 0x3f, sizeof(d));
39             while (s--) {
40                 int u, v, w;
41                 cin >> u >> v >> w;
42                 d[u][v] = d[v][u] = w;
43             }        
44             rep(k, 1, c + 1) rep(i, 1, c + 1) rep(j, 1, c + 1)
45                 d[i][j] = min(d[i][j], max(d[i][k], d[k][j]));
46             if (cas != 1) cout << endl;
47             cout << "Case #" << cas++ << endl;
48             while (q--) {
49                 int s, t;
50                 cin >> s >> t;
51                 if (d[s][t] == INF) cout << "no path" << endl;
52                 else cout << d[s][t] << endl;
53             }
54         }
55         return 0;
56     }

 

以上是关于UVAOJ 10048 - Audiophobia Floyd的主要内容,如果未能解决你的问题,请参考以下文章

UVA - 10048 Audiophobia (Floyd应用)

UVa10048 Audiophobia (Floyd)

UVA 10048 Audiophobia floyd

UVA10048 噪音恐惧症 Audiophobia

UVa10048_Audiophobia(最短路/floyd)(小白书图论专题)

杂题 UVAoj 107 The Cat in the Hat