您的位置:首页 > 运维架构

UVa 10048 Audiophobia

2014-02-19 08:14 519 查看
Problem B: Audiophobia
Consider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not have this luxury. For, as you know, we are the dwellers of one of the most polluted cities on earth. Pollution is everywhere, both in the environment and in society and our lack of consciousness is simply aggravating the situation.

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.

#include<iostream>
#include<algorithm>
#include<cstdio>
#define INF 0x7fffffff

using namespace std;

int c,s,q;
int Map[150][150];

int main()
{
int kase=0;

while(scanf("%d %d %d",&c,&s,&q)==3&&(c||s||q))
{
kase++;
if(kase>1)
puts("");
printf("Case #%d\n",kase);

for(int i=1;i<=c;i++)
for(int j=1;j<=c;j++)
Map[i][j]=INF;

int c1,c2,d;
for(int i=1;i<=s;i++)
{
scanf("%d %d %d",&c1,&c2,&d);
Map[c1][c2]=Map[c2][c1]=d;
}

for(int k=1;k<=c;k++)
for(int i=1;i<=c;i++)
for(int j=1;j<=c;j++)
Map[i][j]=min(Map[i][j],max(Map[i][k],Map[k][j]));

for(int i=1;i<=q;i++)
{
scanf("%d %d",&c1,&c2);
if(Map[c1][c2]==INF)
puts("no path");
else
printf("%d\n",Map[c1][c2]);
}
}

return 0;
}


[C++]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: