UVa 10048 Audiophobia(最短路&Floyd)

Android13 CarPowerManagementService onApPowerStateChange流程分析 如下为CarPower上电的流程图:下面我们从代码角度分析:在CPMS的init方法中会调用onApPowerStateChange(CpmsState.WAIT_FOR_VHAL, CarPowerManager.STATE_WAIT_FOR_VHAL); 设置ApPowerState为STATE_WAIT_FOR_VHAL: 在onApPowerStateChange中调用PowerHandler 的handlePowerStateChange方法: 在handlePowerStateChang 阅读详情

10048 - Audiophobia

Time limit: 3.000 seconds

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

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.

To get from crossing A to crossing G you may follow the following path: A­C­F­G. In that case you must be capable of tolerating sound intensity as high as 140 decibels. For the paths A­B­E­G, A­B­D­G and A­C­F­D­G you must tolerate respectively 90, 120 and 80 decibels of sound intensity. There are other paths, too. However, it is clear thatA­C­F­D­G is the most comfortable path since it does not demand you to tolerate more than 80 decibels.

In this problem, given a city map you are required to determine the minimum sound intensity level you must be able to tolerate in order to get from a given crossing to another.

Input 

The input may contain multiple test cases.

The first line of each test case contains three integers $C (\le 100)$, $S (\le1000)$ and$Q (\le 10000)$ where C indicates the number of crossings (crossings are numbered using distinct integers ranging from 1 to C), S represents 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 ( $c_1 \ne c_2$) is d decibels.

Each of the next Q lines contains two integers c1 and c2 ( $c_1 \ne c_2$) 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.

Output 

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.

Sample Input 

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

Sample Output 

Case #1
80
60
60
 
Case #2
40
no path
80

题意:求图G中所有从A到B的路径中,权值最大的一条边的最小值。

思路:Floyd

完整代码:

/*0.022s*/

#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 102;
const int INF = 1000000000;//还行

int d[N][N], n, m, Q;

inline void read_graph()
{
	for (int i = 1; i < N; ++i)
	{
		d[i][i] = INF;
		for (int j = i + 1; j < N; ++j)
			d[i][j] = d[j][i] = INF;
	}//对称一下~

	int a, b, c;
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d%d", &a, &b, &c);
		d[a][b] = d[b][a] = c;
	}
}

inline void Floyd()
{
	for (int k = 1; k <= n; ++k)
	{//每k一次表示多走一步
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= n; ++j)
			{
				int tmp = max(d[i][k], d[k][j]);//找到此路上的最大边
				if (tmp < d[i][j])//最大边的最小值
					d[i][j] = tmp;
				//printf("%d ", d[i][j]);
			}
			//printf("\n");
		}
		//printf("\n");
	}
}

inline void output()
{
	int u, v;
	while (Q--)
	{
		scanf("%d%d", &u, &v);
		if (d[u][v] != INF)
			printf("%d\n", d[u][v]);
		else
			printf("no path\n");
	}
}

int main()
{
	scanf("%d%d%d", &n, &m, &Q);
	read_graph();
	Floyd();
	printf("Case #1\n");
	output();
	int cas = 2;
	while (scanf("%d%d%d", &n, &m, &Q), n)
	{
		read_graph();
		Floyd();
		puts("");
		printf("Case #%d\n", cas++);
		output();
	}
	return 0;
}



【微信小程序】微信小程序 manifest.json 配置 ES6 转 ES5 开关:3步让你的代码兼容性更强 ES6(ECMAScript 6)是 JavaScript 的最新标准,引入了许多新的语法和特性,如箭头函数、模板字符串、解构赋值等。然而,不是所有的环境都支持 ES6,特别是旧版本的浏览器和一些特定的运行环境。为了确保代码的兼容性,我们需要将 ES6 代码转换为 ES5 代码。通过本文的详细讲解,相信你已经学会了如何在文件中配置微信小程序的 ES6 转 ES5 开关。这个小小的配置步骤能够显著提高代码的兼容性和稳定性。如果你有任何问题或需要进一步的帮助,欢迎随时留言交流。 阅读详情

相关推荐

Moltemplate建模----水盒子data文件

1功能介绍 Moltemplate是LAMMPS官方支持的建模工具之一,适用于LAMMPS建模。该程序创建了一种简单的文件格式来存储分子定义和力场,即模板LT。LT文件包含与特定分子有关的所有文本(包括坐标,键拓扑,角度,力场参数,约束,组和修复)。 Moltemplate可以复制分子,对其进行自定义,然后用它作为构建更大、更复杂分子的基础。构建后,可以自定义...

元素魔方科研服务 2594

uva 10048 - Audiophobia

Problem B: Audiophobia 噪音恐惧症 Consider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. 你是幸运的!你是幸运的仍有呼吸和快乐的参加这次竞赛 But we apprehend that m

lj102800的专栏 574

机器人系统能用MQTT5.0代替ROS2吗?

更为灵活和友好的方案是通过把ROS(Robot Operating System)与MQTT(Message Queuing Telemetry Transport)协议相结合的解决方案,利用MQTT的轻量级、跨平台和广泛适用性特点,扩展ROS系统的通信能力,或将非ROS系统接入ROS网络。

QzmAIoT 2161

Audiophobia UVA - 10048 噪音恐惧症 最短路

题目链接 输入一个C个点S条边(C≤100,S≤1000)的无向带权图,边权表示该路径上的噪声值。当噪声值太大时,耳膜可能会受到伤害,所以当你从某点去往另一个点时,总是希望路上经过的最大噪声值最小。输入一些询问,每次询问两个点,输出这两点间最大噪声值最小的路图。例如,在图中,A到G的最大噪声值为80,是所有其他路径中最小的(如ABEG的最大噪声值为90)。 【分析】 本题的做法十分简单:...

Nicolas的博客 1152

别再让会议变‘回音壁’:手把手教你调优WebRTC的AEC3回声消除(附实战代码)

本文深入解析WebRTC的AEC3回声消除技术,提供从参数调优到声学环境适配的实战指南。通过诊断回声特征、解剖核心参数(如filter.length_blocks和delay_estimate_smoothing)以及应对特殊场景(如密闭空间与开放办公区),帮助开发者有效解决视频会议中的回声问题,提升语音通信质量。附有实战代码和调试工具,适合需要优化实时通信体验的开发者。

weixin_29220405的博客 171

图像去雾新思路:手把手教你复现DEA-Net中的“细节增强卷积”与PyTorch实现

本文详细解析了DEA-Net中的'细节增强卷积'(DEConv)与PyTorch实现,通过多分支差分卷积和重参数化技术,显著提升单图像去雾效果。文章从数学原理到代码实现,手把手指导复现这一创新架构,帮助开发者在保持轻量化的同时实现41dB以上的PSNR指标,适用于自动驾驶、遥感监测等关键领域。

weixin_30323631的博客 505

Audiophobia

UVa 10048 这道题只需要在Floyd算法稍微改一下就行了,求出间接能到达一点的最大值,和 本身求出最小值就行了。 #include #define INF 100000005 const int maxn = 105; int map[maxn][maxn], n, m; void init ( ) { for ( int i = 0; i <= n; i ++ )

Rookie的博客 926

JavaFX 表视图

我们可以使用来自 JavaFX API 的 TableView,TableColumn 和 TableCell 类以表格形式表示数据。通过实现数据模型和应用单元工厂来填充表中的数据。表类可以按列排序数据,并在必要时调整列大小。

2012年开始工作,全栈开发老兵,目前已是一个老师,分享这么多年的心得体会 404

OJ算法分析题库(4)

源代码部分: 代码部分:

weixin_51339377的博客 1035

Python爬虫实战:逆向工程与异步爬虫技术,高效抓取国家知识产权局专利数据

相比于传统的Selenium,Playwright由微软开发,支持多浏览器(Chromium, Firefox, WebKit),API更现代,执行速度更快,并且能轻松录制用户操作生成代码。通常,列表中的摘要信息是缩略的,我们需要进入每个专利的详情页获取完整信息(如主权要求、法律状态等)。我们的第一步是手动操作一遍搜索流程,并用Playwright的“录制”功能或开发者工具,找出真正返回专利数据的那一个或多个网络请求。以友好的、对人类行为模拟的方式爬取数据是基本的网络礼仪,也能有效避免你的IP被封锁。

2201_76125261的博客 2419

【Bug已解决】Anthropic tool_result 找不到对应 tool use id 解决方案

方案适用场景推荐指数每个tool_use必须生成对应tool_result最基础的原则,所有Harness都必须遵守⭐⭐⭐⭐⭐裁剪历史时成对处理实现了上下文裁剪/压缩逻辑的Harness⭐⭐⭐⭐⭐并行工具调用结果数量校验支持多工具并行调用的场景⭐⭐⭐⭐使用官方SDK高层封装不需要特别定制消息组装逻辑⭐⭐⭐⭐请求前主动校验中间件追求生产级健壮性,提前拦截问题⭐⭐⭐⭐⭐这类报错,本质上是。

一键难忘的博客 1万+

2021-10-26

图书馆连续打卡第三天 文章目录噪音恐惧症(Audiophobia,UVa10048) 噪音恐惧症(Audiophobia,UVa10048) 输入一个C个点S条边(C<=100,S<=1000)的无向带权图,边权表示该路径上的噪音值,当噪声值太大时,耳膜可能会受到伤害,所以当你从某点去往另一个点时,总是希望路上经过的最大噪声值最小。输入一些询问,每次询问两个点,输出这两点间最大噪声值最小的路径。 #include"bits/stdc++.h" using namespace st

m0_52318349的博客 353

Harmony:C# 动态代码补丁的5大秘密武器

Harmony 是一个开源库,它允许你在运行时修改托管代码(即使用 .NET 或 Mono 编译的语言编写的应用程序)。它通过利用 AOP(面向切面编程)的思想,可以在不重新编译代码的情况下添加、替换或修改方法的行为。这对于游戏模组(Modding)、插件开发以及调试工具非常有用。安装 Harmony要使用 Harmony,你需要首先安装它。Harmony 作为一个 NuGet 包,可以直接通过 Visual Studio 的 NuGet 包管理器进行安装。安装步骤打开 Visual Studio。

java专栏 1191

UVA10048 Audiophobia 解题报告

对于任意一条至少包含两条边的路径i->j,考虑一个中间点k使得i->j的总长度等于i->k和k->j之和,此时已知路径i->k以及路径k->j各自的最大边权,那么显然i->j的最大边权是取他们的最大值。考虑不同的中间点k,结果可能不同,所以最后还需取一个最小值才是i->j的最佳路径(路径上的最大边权最小)。当噪声值太大时,耳膜可能会受到伤害,所以当你从某点去往另一个点时,总是希望路上经过的最大噪声值最小。输入一些询问,每次询问两个点,输出这两点间最大噪声值最小的路径(输出其最大噪声值即可)。

qq_45554473的博客 409

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

【Audiophobia UVA - 10048 】【Floyd算法】

题目大意:从a城市到b城市的路径中,尽可能让一路上的最大噪音最小。 题目思路:设d [ i ] [ j ]表示 i 到 j 的最大噪音的最小值。 那么d [ i ] [ j ] = min( d[ i ] [ j ] ,max( d [ i ] [ k ] , d [ k ] [ j ]) );AC代码: #include<iostream> #include<cstdio&...

无论多么困难,也要熬下去!!! 84

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

[广义Floyd] UVA10048 噪音恐惧症 Audiophobia

Floyd的运用

阿巴阿巴 319

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Audiophobia(Floyd算法)

个人心得:这在一定途径上完成查询方面还是很吃力,得多锻炼空间能力,不能再每次都看到就后退,要全力应对, 那怕被虐的不要不要的。 这题主要是求俩个端点中所有路径中最大构成的集合中最小的数值,其实开始思想已经到触及到了这一块, 就想着从一直衍生每次都是max更新,但最终点那里还是卡了一下,还有自己的算法很容易就被突兀的途径给打乱了。 Floyd算法挺不错的,进行一点点的改变就好了,他就是保存每...

weixin_30412577的博客 322

UVA - 10048 Audiophobia (floyd+dp)

题目大意:求所有可达路径中最大值最小的一条路,并输出去其最大值。 ju 让我们来看一个例子,看下图: 图中红色的数字代表边的权重。如果我们在最内层检查所有节点X,那么对于A->B,我们只能发现一条路径,就是A->B,路径距离为9。而这显然是不正确的,真实的最短路径是A->D->C->B,路径距离为6。造成错误的原因就是我们把检查所有节点X放在最内层,造成过早的把A到B的最短路径确

小G的ACM之路 735

UVA 10048 - Audiophobia

题目大意: C个点,S条边,Q个询问,存在多组数据输入。 无向图边权非负,问两点间路径中边权最大值集合中,输出最大值最小的那条路径的最大值。 解题思路: 1.Floyd的变形: 如果我们把Floyd算法         变形如下: i--&gt;k,k--&gt;j 的路径最大值和当前i--&gt;j的路径最大值比较,我们选取最大值小的哪一个,Floyd仍然成立。          ...

JustNo 308

Uva10048——Audiophobia

题目的意思,无向图中求某个点到另外一个点的路径上的最大噪声值,最大噪声值比其他路径上的最大噪声值小,比该路径上的噪声大。 最后问的是有q个问题,每个问题存入两个点,求这两点之间的最大噪声值,直接用Floyd算法。 代码: #include #include using namespace std; const int INF = 0xfffffff; int c, s,

XD 749

UVa 10048 噪音恐惧症(Floyd)

https://vjudge.net/problem/UVA-10048 题意: 输入一个C个点S条边的无向带权图,边权表示该路径上的噪声值。输入一些询问,每次询问两个点,输出这两点间最大噪声值最小的路径。 思路: 最简单的方法就是Floyd算法。本来是求长度的,现在求最大噪声值最小的路径,稍微改一下就好了。 d[i][j]=min(d[i][j],max(d[i][k],d[...

weixin_30332705的博客 332

10048 - Audiophobia\\Floyd

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 m

mr_zys的专栏 775

最短路经典题-Audiophobia (Floyd灵活)

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

qq_37280023的博客 596

uva 10048(最短路径)

题意:给出n个城镇,m条 题解: #include #include const int INF = 0x3f3f3f3f; const int N = 105; int g[N][N], t = 1, que, n, m; void floyd() { for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i++) fo

俯瞰风景 1558

10048 - Audiophobia

点击打开链接 用Floyd 算法求任意两个点相通路径中的所有路径长度最长的值。只用FLOYD 和决策改变一下即可。 #include int n,m,t; const int INF = 100000000; const int maxn = 110; int dist[maxn][maxn]; int maxs(int a,int b){ return

码码要洗手 596

10048 Audiophobia--好题

#include #include #include #include #include #include #include #include #include #include #define LL long long #define inf 800000 #define E 1e-9 #define M 100 #define N 105 using namespace std; int

wode的专栏 611
上一篇: UVa 10105 Polynomial Coefficients(组合数学)
下一篇: 一位ACMer过来人的心得
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值