However, for the time being, we will consider only one type of pollution -- the sound pollution. The loudness or intensity level of sound is usually measured in decibels and sound having intensity level 130 decibels or higher is considered painful. The intensity level of normal conversation is 60-65 decibels and that of heavy traffic is 70-80 decibels.
Consider the following city map where the edges refer to streets and the nodes refer to crossings. The integer on each edge is the average intensity level of sound (in decibels) in the corresponding street.
To get from crossing A<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vc3Ryb25nPiB0byBjcm9zc2luZyA8c3Ryb25nPkc8L3N0cm9uZz4geW91IG1heSBmb2xsb3cgdGhlIGZvbGxvd2luZyBwYXRoOiA8c3Ryb25nPkEtQy1GLUc8L3N0cm9uZz4uIEluIHRoYXQgY2FzZSB5b3UgbXVzdCBiZSBjYXBhYmxlIG9mIHRvbGVyYXRpbmcgc291bmQgaW50ZW5zaXR5IGFzIGhpZ2ggYXMgMTQwIGRlY2liZWxzLgogRm9yIHRoZSBwYXRocyA8c3Ryb25nPkEtQi1FLUc8L3N0cm9uZz4sIDxzdHJvbmc+QS1CLUQtRzwvc3Ryb25nPiBhbmQgPHN0cm9uZz5BLUMtRi1ELUc8L3N0cm9uZz4geW91IG11c3QgdG9sZXJhdGUgcmVzcGVjdGl2ZWx5IDkwLCAxMjAgYW5kIDgwIGRlY2liZWxzIG9mIHNvdW5kIGludGVuc2l0eS4gVGhlcmUgYXJlIG90aGVyIHBhdGhzLCB0b28uIEhvd2V2ZXIsIGl0IGlzIGNsZWFyIHRoYXQgPHN0cm9uZz5BLUMtRi1ELUc8L3N0cm9uZz4gaXMgdGhlCiBtb3N0IGNvbWZvcnRhYmxlIHBhdGggc2luY2UgaXQgZG9lcyBub3QgZGVtYW5kIHlvdSB0byB0b2xlcmF0ZSBtb3JlIHRoYW4gODAgZGVjaWJlbHMuPC9wPgo8cD5JbiB0aGlzIHByb2JsZW0sIGdpdmVuIGEgY2l0eSBtYXAgeW91IGFyZSByZXF1aXJlZCB0byBkZXRlcm1pbmUgdGhlIG1pbmltdW0gc291bmQgaW50ZW5zaXR5IGxldmVsIHlvdSBtdXN0IGJlIGFibGUgdG8gdG9sZXJhdGUgaW4gb3JkZXIgdG8gZ2V0IGZyb20gYSBnaXZlbiBjcm9zc2luZyB0byBhbm90aGVyLjwvcD4KPHA+PC9wPgo8aDI+SW5wdXQgPC9oMj4KPHA+VGhlIGlucHV0IG1heSBjb250YWluIG11bHRpcGxlIHRlc3QgY2FzZXMuPC9wPgo8cD5UaGUgZmlyc3QgbGluZSBvZiBlYWNoIHRlc3QgY2FzZSBjb250YWlucyB0aHJlZSBpbnRlZ2VycyA8aW1nIHdpZHRoPQ=="76" height="34" align="MIDDLE" border="0" src="http://www.2cto.com/uploadfile/Collfiles/20140419/20140419082454142.gif" alt="$C (\le 100)$">, and where Cindicates the number of crossings (crossings are numbered using distinct integers ranging from 1 to C), Srepresents the number of streets and Q is the number of queries.
Each of the next S lines contains three integers: c1, c2 and d indicating that the average sound intensity level on the street connecting the crossings c1 and c2 ( ) is d decibels.
Each of the next Q lines contains two integers c1 and c2 ( ) asking for the minimum sound intensity level you must be able to tolerate in order to get from crossing c1 to crossing c2.
The input will terminate with three zeros form C, S and Q.
For each test case in the input first output the test case number (starting from 1) as shown in the sample output. Then for each query in the input print a line giving the minimum sound intensity level (in decibels) you must be able to tolerate in order to get from the first to the second crossing in the query. If there exists no path between them just print the line ``no path".
Print a blank line between two consecutive test cases.
7 9 3 1 2 50 1 3 60 2 4 120 2 5 90 3 6 50 4 6 80 4 7 70 5 7 40 6 7 140 1 7 2 6 6 2 7 6 3 1 2 50 1 3 60 2 4 120 3 6 50 4 6 80 5 7 40 7 5 1 7 2 4 0 0 0
Case #1 80 60 60 Case #2 40 no path 80
#include#include #include #define INF 20000000 using namespace std; int c,s,f; int dis[105][105]; void floyd() { for(int k=1;k<=c;k++) { for(int i=1;i<=c;i++) { for(int j=1;j<=c;j++) { dis[i][j]=min(dis[i][j],max(dis[i][k],dis[k][j])); } } } } int main() { int u,v,w,a,b,cas=1; while(scanf("%d%d%d",&c,&s,&f)!=EOF) { if(c==0 && s==0 && f==0) break; if(cas!=1) printf("\n"); printf("Case #%d\n",cas++); for(int i=1;i<=c;i++) { for(int j=1;j<=c;j++) { dis[i][j] = i==j?0:INF; } } for(int i=0;i