题意:

输入两个正整数N和K(2<=N<=200),代表城市的数量和道路的数量。接着输入起点城市的名称(所有城市的名字均用三个大写字母表示),接着输入N-1行每行包括一个城市的名字和到达该城市所能获得的快乐,接着输入M行每行包括一条道路的两端城市名称和道路的长度。输出从起点城市到目标城市"ROM"获得最大快乐且经历道路长度最短的道路条数和经历的道路长度和获得的快乐总数以及其中经过城市最少的那条路的到达每个城市所获得的平均快乐。下一行输出这条路的路径,城市名之间用"->"连接。

AAAAAccepted code:

//用pre数组记录最大快乐最小开销的道路路径会比用DFS暴力搜索快四到五倍

【PAT甲级】1087 All Roads Lead to Rome (30 分)(dijkstra+dfs或dijkstra+记录路径)的更多相关文章

  1. PAT甲级1087. All Roads Lead to Rome

    PAT甲级1087. All Roads Lead to Rome 题意: 确实有从我们这个城市到罗马的不同的旅游线路.您应该以最低的成本找到您的客户的路线,同时获得最大的幸福. 输入规格: 每个输入 ...

  2. PAT 甲级 1087 All Roads Lead to Rome(SPFA+DP)

    题目链接 All Roads Lead to Rome 题目大意:求符合题意(三关键字)的最短路.并且算出路程最短的路径有几条. 思路:求最短路并不难,SPFA即可,关键是求总路程最短的路径条数. 我 ...

  3. PAT 甲级 1087 All Roads Lead to Rome

    https://pintia.cn/problem-sets/994805342720868352/problems/994805379664297984 Indeed there are many ...

  4. PAT甲级练习 1087 All Roads Lead to Rome (30分) 字符串hash + dijkstra

    题目分析: 这题我在写的时候在PTA提交能过但是在牛客网就WA了一个点,先写一下思路留个坑 这题的简单来说就是需要找一条最短路->最开心->点最少(平均幸福指数自然就高了),由于本题给出的 ...

  5. [图的遍历&多标准] 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 ...

  6. 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 ...

  7. 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 ...

  8. PAT (Advanced Level) 1087. All Roads Lead to Rome (30)

    暴力DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  9. 1087. All Roads Lead to Rome (30)

    时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Indeed there are many different ...

随机推荐

  1. TD - 单选框 - RadioButton

    基本方法 Html - 默认选中 //checked="true" - 默认选中 <input dojoType="bootstrap.form.RadioButt ...

  2. php基础系列之 数据的存储和读取

    ·文件处理 ·写入一个文件 1,打开这个文件.如果这个文件不存在,需要先创建它 2,将数据写入这个文件 3,关闭这个文件 ·从一个文件读出数据 1,打开这个文件.如果这个文件不能打开(例如,文件不存在 ...

  3. flume--exec源

    创建a2.conf文件并且编写 Sources 类型是exec 配置文件如下 启动集群 启动flume 产生临时文件 ...tmp 关闭临时文件 再次写入文本,会再次产生一个临时文件.截图左边是一个内 ...

  4. 第一个Mybatis项目

    第一个Mybatis项目 一.创建普通Maven项目 1.配置pom.xml文件 <dependencies> <!--mysql驱动--> <dependency> ...

  5. 滑动窗口-洛谷T1866(单调队列)

    咕咕咕 单调队列板子题 一.基本 1.单调队列: 特殊的双端队列,内部元素.分为最大队列(单调递增)和最小队列(单调递减)两种 二.应用 本题中:大部分单调队列优化的动态规划问题都和定长连续子区间的最 ...

  6. 解决VS2013报错fopen、sprintf等函数安全的问题

    VS2013中使用fopen.sprintf等函数是会出现安全问题: error C4996: 'fopen': This function or variable may be unsafe. Co ...

  7. ACM的探索之Everything is Generated In Equal Probability! 后序补充丫!

    Problem Desciption: 百度翻译后的汉化: 参见博客:https://www.cnblogs.com/zxcoder/p/11253099.html https://blog.csdn ...

  8. kali 插上耳机没声音

    这几天装kali装的真是心力憔悴,好不容易勉强可以使用了,插上耳机想要放松下,结果没有声音? excusu me? 在经历各种方法之后终于找到了解决方法,亲测可行. 1.先打开终端,输入systemc ...

  9. c#项目调用Python模块的方法

    将Python模块用pyinstaller打包成exe程序 下载安装UPX((http://upx.sourceforge.net/)) ,并把路径加到环境变量中. UPX是开源的加壳和压缩exe的程 ...

  10. ListVIew中包含水平滑动控件,左右滑动时容易触发上下滑动

    自定义ListView import android.content.Context;import android.util.AttributeSet;import android.view.Moti ...