1003. Emergency (25)-PAT

centos断电重启卡在登录前界面的问题解决 出现这个情况的原因猜测是断电,启动后就卡在登录前界面,只有网络是通的,其他服务貌似都没正常启动,ssh远程终端也连不上 ctrl+alt+1,切换到详细信息模式下看到这样的错误: 就是文件系统xfs有损坏 查资料都说是需要通过xfs_repair来修复,但这里进不了终端了,解决办法是进入”单用户模式”: 开机时进入如下界面: 按e键出现下面界面 按方向键下,定位到最后,找到“ro”一行,ro的意思是readonly,将“ro”替换成 rw init=/sysroot/bin/sh,. 阅读详情

1003. Emergency (25)

时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some other city, your job is to lead your men to the place as quickly as possible, and at the mean time, call up as many hands on the way as possible.

Input

Each input file contains one test case. For each test case, the first line contains 4 positive integers: N (<= 500) - the number of cities (and the cities are numbered from 0 to N-1), M - the number of roads, C1 and C2 - the cities that you are currently in and that you must save, respectively. The next line contains N integers, where the i-th integer is the number of rescue teams in the i-th city. Then M lines follow, each describes a road with three integers c1, c2 and L, which are the pair of cities connected by a road and the length of that road, respectively. It is guaranteed that there exists at least one path from C1 to C2.

Output

For each test case, print in one line two numbers: the number of different shortest paths between C1 and C2, and the maximum amount of rescue teams you can possibly gather.
All the numbers in a line must be separated by exactly one space, and there is no extra space allowed at the end of a line.

Sample Input
5 6 0 2
1 2 1 5 3
0 1 1
0 2 2
0 3 1
1 2 1
2 4 1
3 4 1
Sample Output
2 4
迪杰特拉斯最短路径
#include<iostream>
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
#define N 1000
int mapt[N][N];
int dist[N];
int visit[N];
int team[N];
int total[N];
int num_path[N];
#define  maxnum 0xfffffff
void  emergency(int n,int s)
{
    int i,j,k,preteams,u;
    for(i=0;i<n;i++){
        visit[i]=0;
		dist[i]=maxnum;
        total[i]=team[i];
		dist[i]=mapt[s][i];
    }
	dist[s]=0;
	total[s]=team[s];
	preteams=total[s];
    visit[s]=1;
    for(i=0;i<n;i++)
	{
		int tmp=maxnum;
		for(j=0;j<n;j++){
			if(visit[j]==0&&dist[j]<tmp)
			{
				tmp=dist[j];
				u=j;
			}
		}
		visit[u]=1;
		for(j=0;j<n;j++){
			if(visit[j]==0&&mapt[u][j]!=maxnum){
				if(dist[j]>dist[u]+mapt[u][j])
				{   
					dist[j]=dist[u]+mapt[u][j];
					total[j]=total[u]+team[j];
					num_path[j]=num_path[u];
				}
			   else if(dist[j]==dist[u]+mapt[u][j])
				{
					total[j]=max(total[j],total[u]+team[j]);
					if(mapt[s][u]!=0)
						num_path[j]+=num_path[u];
				}
			}

		}
    }
}
int main()
{
    int i,j,k;
	int n,c1,c2;
	long m;
    cin>>n;
    cin>>m;
    cin>>c1;
    cin>>c2;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++)
        {
            mapt[i][j]=maxnum;
        }
		mapt[i][i]=0;
	}
    for(i=0;i<n;i++){
       cin>> team[i];
	   num_path[i]=1;
    }
    for(k=0;k<m;k++){
        cin>>i;
        cin>>j;
        cin>>mapt[i][j];
        mapt[j][i]=mapt[i][j];
    }
    emergency(n,c1);
	if(c1!=c2){
		total[c2]+=total[c1];
	}
    cout<<num_path[c2]<<" "<<total[c2]<<endl;
    return 0;

}


STM32F1的USB接口-自定义HID 设置USB VID:1155 PID :22352。 阅读详情

相关推荐

Vue3项目实战:CKEditor5富文本编辑器从安装到隐藏不需要的功能

本文详细介绍了在Vue3项目中集成并深度定制CKEditor5富文本编辑器的完整流程。通过分析其模块化架构,指导开发者从标准构建出发,移除图片、表格等冗余插件,创建专属轻量构建,从而显著减小打包体积并提升用户体验。文章结合实战代码,涵盖了环境搭建、自定义构建配置、高级优化技巧等关键步骤。

weixin_29016833的博客 285

记一次XFS文件系统崩溃的处理

1、问题出现 当使用rpm安装服务时,出现如下问题,当使用yum时也是一样 查了/var/log/messages发现以下错误,看起来是XFS的问题 可以发现dm-0实际是bel-root的问题,查了网上很多解决方法都是说要使用xfs_repair去修复对应的磁盘,但是我这里是没有用的,会报xfs_repair: /dev/dm-0 contains a mounted filesystem ...

dhRainer的博客 8572

请叫我鱼拆,2024扫地机器人的第一次拆机

从背面可以看出,这个机器人是两轮差速模型,两个驱动轮,一个万向轮,驱动轮位于机器人中心位置,这样原地旋转的圆心就是机器人的中心。可以看到设备已经连接,但是没有办法进shell,厂家应该有做了安全保护之类的,有知道从这个口可以登录系统办法的小伙伴可以后台留言。但这台机器人一直报警说,机器人轮子离地,小鱼 估计是防跌落模块有问题,误触发了,所以打算先拆机看看。接着小鱼试了下,机器可以开机,然后给他重新配置wifi,连上 米家。Allwinner,全志的片子,不知道哪个型号的,看产品id,应该支持adb。

生活不止眼前的苟且 3932

xfs文件系统修复-xfs_repair

公司虚拟平台中六台虚拟机,Centos操作系统,因为停电,坏了五台,无比郁闷,开发环境都在上面部署着。 如果全部重新安装费时费力。 安装的时候选择了xfs文件系统。 网上查询到xfs文件系统可以通过xfs_repair命令进行修复,就进行了尝试。 ...

天道 4万+

DeepSeek API调用太复杂?OneAPI一站式聚合解决方案

本文介绍了OneAPI如何作为一站式聚合解决方案,简化DeepSeek API的调用流程。通过统一接口、智能路由和模型映射等核心功能,OneAPI大幅降低了多API适配的复杂性,提升开发效率。文章还提供了详细的部署指南和高阶使用技巧,帮助开发者快速实现API聚合管理。

weixin_27215337的博客 381

云桌面如何部署?云桌面系统方案部署详细教程

云桌面作为一种比较新的技术工具,核心解决的场景是方便设计师的灵活办公,本身技术就是非常的灵活性,所以在安装部署方面青椒云也做到了十足的灵活。

2301_79113726的博客 1634

centos8 启动失败

进入救援模式 http://www.7vo.cn/article/51.html https://blog.csdn.net/dhrainer/article/details/91453450 :在linux16这行的后面输入“rd.break console=tty0”然后按“ctrl+x“如下图 进入安全模式后,使用umount /dev/mapper/bel-root去卸载当前的卷,(这一步很重要),而后执行xfs_repair /dev/mapper/bel-ro...

sun007700的专栏 2516

使用DrissionPage和自动化技术实现得物鞋子信息爬取

本文介绍了一个基于DrissionPage技术的得物鞋子信息采集系统,能自动化采集商品图片、价格等数据并保存为Excel。系统采用浏览器模拟技术处理动态加载内容,通过XPath定位元素,实现智能交互和完整数据采集。关键技术包括:图片URL提取与下载、Excel数据集成与图片嵌入、文件名安全处理等。项目适用于市场分析和学术研究,强调必须遵守法律法规和平台规则,仅用于非商业用途。与API爬虫相比,浏览器自动化能更好处理现代Web应用,但需注意知识产权保护。

那些看似不起波澜的日复一日,会在某天让你看到坚持的意义 1666

解决XFS (dm-0): metadata I/O error: block 0x305ced8 ("xfs_trans_read_buf_map") error 74 numblks 8

[root@rac2 ~]# tail -50 /var/log/messages Nov 14 19:08:54 rac2 kernel: XFS (dm-0): Metadata CRC error detected at xfs_dir3_block_read_verify+0x5e/0x110 [xfs], xfs_dir3_block block 0x305ced8 Nov 14 19...

sqlora的专栏 2万+

【人工智能时代】-什么是MCP?本地如何开发MCP Server

MCP(Model Context Protocol)全称模型上下文协议,是由 Anthropic 推出的一种开放标准,旨在统一大型语言模型(LLM)与外部数据源和工具之间的通信协议。掌握更多的信息控制更多的工具在没有联网搜索之前,大模型的数据来源只有训练数据的时候以及推理我们告诉他的东西。所以后来的rag、知识库都是让AI掌握更多的信息,而MCP的出现是为了让大模型控制更多的工具,赋予更多能力。在本篇文章中,基于 Python 完成了一个简单的 MCP Server 的开发。

xiaoli8748的专栏 1993

小米15修复“NV损坏” 去除主板校验电阻步骤解析与图示

小米15系列将搭载骁龙8至尊版处理器,采用台积电3nm工艺。文章分析了手机出现"NV损坏"故障的表现及修复方法,包括通信异常、系统启动问题等典型症状,并介绍了去除主板校验电阻和刷写工程固件两种修复方案。重点讲解了去除主板电阻后刷写QCN文件的操作流程,强调在维修过程中需要结合分析与思考。适用于小米15系列特定机型(24129PN74G/I/C)的硬件修复。

小马哥的专栏 313

PAT(甲级)1003.Emergency(25)

PAT 1003.Emergency(25) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams...

乐行僧的博客 334

【Unity】 预制体Prefab使用说明

在 Unity 中,Prefab 是一个可以预先制作并重复使用的 GameObject 或组件集合,Prefab 中的 GameObject 可以有子对象和其他组件。

灵境引路人 2850

PAT甲级 - 1003 Emergency (25 分)

题目链接:(PAT甲级)1003 Emergency (25 分) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of ...

248

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

PAT甲级1003 Emergency (25分)

PAT甲级1003 Emergency (25分) 题目: 解题思路:由于是第一次接触到图的问题,所以重温了一下数据结构的Dijkstra算法吧,不太会写,在搜集了各种资料之后终于AC,所以做了详细的注释,可能下次遇到Dijkstra会好受一点吧 附上AC代码: #include <cstdio> #include <cstring> #include <algori...

weixin_43795683的博客 221

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

[PAT-Advanced]A1003 Emergency (25)

理解和记忆Dijkstra算法

Duke 293

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

PAT 1003 Emergency(25)Python

题目描述1003. Emergency (25)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams

日复一日,年复一年 949

Pat 1003 Emergency (25)

1003Emergency(25分) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams...

YIU 189

PAT A1003 Emergency (25分)

PAT A1003 Emergency (25分) 题目 原题链接 题目大意 输入每个城市医疗队的数目,以及相连城市之间的距离,计算求出原城市到目的城市最短路径的路径数,以及最多能聚集医疗队的数目 大体思路 该题是一个典型的dijkstra+DFS的模板题目,掌握了该模板,就可以解决这一类典型问题。 代码 #include<stdio.h> #include<algorithm&...

qq_41706836的博客 181

PAT(甲级)1003 Emergency (25 分)

题目来源: PAT(甲级)1003 Emergency (25 分) 题目描述: Sample Input: 5 6 0 2 1 2 1 5 3 0 1 1 0 2 2 0 3 1 1 2 1 2 4 1 3 4 1 Sample Output: 2 4 题目翻译: 作为一个城市的紧急救援队队长,你会得到一张你所在国家的特别地图。这张地图显示了几个分散的城市,由一些道路连接起来。地图上标出了...

sinat_41835935的博客 249

PAT真题练习(甲级)1003 Emergency (25 分)

PAT真题练习(甲级)1003 Emergency (25 分) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of re...

Be Quick & Clever & Lucky 328

【PAT甲级题解记录】1003 Emergency (25 分)

对于单源最短路径(这道题也应该不会出现负边),一般我们最常用的就是dijkstra算法,但这里不单单是求最短路径,但是依旧可以用这个算法,算是dijkstra求最短路径的变题。

retr0的博客 539

Day1: [PAT] 1003 Emergency (25 分)

Day1: [PAT] 1003 Emergency (25 分) 题源: 来自PAT甲级题库1003:https://pintia.cn/problem-sets/994805342720868352/problems/994805523835109376 思路: Dijkstra算法的“双优先级版”,首先要熟练Dij算法的基本型。本题的第一优先级是路径权值,第二优先级是救援队人数(点的权值呗...

qq2215459786的博客 155

PAT 甲级 1003 Emergency 25分

题目描述 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and ...

qq_26073557的博客 314

PAT 1003 Emergency (25)

写了一段时间的HDU上的搜索,现在回来写这道PAT上的,顿时觉得PAT上的难度确实是要小一些的,但是这里暴露了自己的问题,以前都不怎么用宏定义,在这里心血来潮用了一次,一直报错但是一直没找到问题,这里要提醒自己,宏定义常量的时候后面不要加; #include #include #define MAX1 999 int start,ends,n,m,visit[505],map[505]

Whisker_yu的专栏 593

PAT A1003 Emergency (25 分)

1003Emergency(25分) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams...

树叶子的博客 291
上一篇: 1004. Counting Leaves (30)-PAT
下一篇: 1006. Sign In and Sign Out (25)-PAT
zoushidexing
博客等级 码龄18年 70粉丝 171原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值