【PAT甲级】1087 All Roads Lead to Rome (30 分)(dijkstra+dfs或dijkstra+记录路径)
题意:
输入两个正整数N和K(2<=N<=200),代表城市的数量和道路的数量。接着输入起点城市的名称(所有城市的名字均用三个大写字母表示),接着输入N-1行每行包括一个城市的名字和到达该城市所能获得的快乐,接着输入M行每行包括一条道路的两端城市名称和道路的长度。输出从起点城市到目标城市"ROM"获得最大快乐且经历道路长度最短的道路条数和经历的道路长度和获得的快乐总数以及其中经过城市最少的那条路的到达每个城市所获得的平均快乐。下一行输出这条路的路径,城市名之间用"->"连接。
AAAAAccepted code:
//用pre数组记录最大快乐最小开销的道路路径会比用DFS暴力搜索快四到五倍
【PAT甲级】1087 All Roads Lead to Rome (30 分)(dijkstra+dfs或dijkstra+记录路径)的更多相关文章
- PAT甲级1087. All Roads Lead to Rome
PAT甲级1087. All Roads Lead to Rome 题意: 确实有从我们这个城市到罗马的不同的旅游线路.您应该以最低的成本找到您的客户的路线,同时获得最大的幸福. 输入规格: 每个输入 ...
- PAT 甲级 1087 All Roads Lead to Rome(SPFA+DP)
题目链接 All Roads Lead to Rome 题目大意:求符合题意(三关键字)的最短路.并且算出路程最短的路径有几条. 思路:求最短路并不难,SPFA即可,关键是求总路程最短的路径条数. 我 ...
- PAT 甲级 1087 All Roads Lead to Rome
https://pintia.cn/problem-sets/994805342720868352/problems/994805379664297984 Indeed there are many ...
- PAT甲级练习 1087 All Roads Lead to Rome (30分) 字符串hash + dijkstra
题目分析: 这题我在写的时候在PTA提交能过但是在牛客网就WA了一个点,先写一下思路留个坑 这题的简单来说就是需要找一条最短路->最开心->点最少(平均幸福指数自然就高了),由于本题给出的 ...
- [图的遍历&多标准] 1087. All Roads Lead to Rome (30)
1087. All Roads Lead to Rome (30) Indeed there are many different tourist routes from our city to Ro ...
- 1087 All Roads Lead to Rome (30)(30 分)
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your ...
- PAT甲级——A1087 All Roads Lead to Rome【30】
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your ...
- PAT (Advanced Level) 1087. All Roads Lead to Rome (30)
暴力DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- 1087. All Roads Lead to Rome (30)
时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Indeed there are many different ...
随机推荐
- Execl导出
1.ExeclUtil.java public class ExcelUtil { public static <T> HSSFWorkbook exprotExcel(String ti ...
- Tomcat/conf/server.xml文件中docBase和path的说明
Tomcat的项目部署方式有以下三种: 1.直接把项目复制到Tomcat安装目录的webapps目录中,这是最简单的一种Tomcat项目部署的方法.2.在tomcat安装目录中有一个conf文件夹,打 ...
- Weighted Visibility Graph With Complex Network Features in the Detection of Epilepsy
Their data five data set, 100 single channel of EEG signals, each channel EEG has 4097 data point. t ...
- C++-对象指针的滥用
C++ 中经常出现使用对象指针,而不是直接使用对象本身的代码,比如下面这个例子: Object *myObject = new Object; 而不是使用: myObject.testFunc(); ...
- 函数match应打印s中从ch1到ch2之间的所有字符,并且返回ch1的地址。
1 char *match( char *s, char ch1, char ch2 ){ ; ; ; while(s[len]){ len++; } *len+];//防止s字符串全满导致t溢出 * ...
- 【算法学习记录-排序题】【PAT A1012】The Best Rank
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- vue的$on,$emit
使用 $on(eventName) 监听事件使用 $emit(eventName) 触发事件 Api 中的解释: vm.$emit( event, […args] ) 参数: {string} eve ...
- [ASP.NET]Web网站与Web应用程序区别
[ASP.NET]Web网站与Web应用程序区别 本文链接:https://blog.csdn.net/a954553391/article/details/86403521 前言:在项目开发中, ...
- 用控制台编译和运行,输出HelloWorld
HelloWorld 建立一个Java文件,文件后缀为.java(Hello.java) public class Hello{ public static void main(String[ ...
- pikaqiu练习平台(XSS(跨站脚本))
XSS(跨站脚本)概述 Cross-Site Scripting 简称为“CSS”,为避免与前端叠成样式表的缩写"CSS"冲突,故又称XSS.一般XSS可以分为如下几种常见类型: ...