题意:

输入两个正整数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. Centos7部署jenkins

    1.       下载rpm包: a)         下载地址:https://pkg.jenkins.io/redhat-stable/ b)         点选一个下载即可,例如点选:“jen ...

  2. HTML5使用JavaScript控制<audio>音频的播放

    1.播放音乐最简单的样例 <audio controls> <source src="horse.mp3" type="audio/mpeg" ...

  3. amazon 1

    # 跨境电商 Amazon 丰富强大的海外站 开店流程 https://www.cifnews.com/article/48921 注册事项以及二审怎么过 https://www.cifnews.co ...

  4. 如何去官网上下载tomcat的linux版本

    1.首先进入官网,进入如下位置 2.进入bin文件夹中下载: 原文链接:https://blog.csdn.net/zdb292034/article/details/82433072

  5. ubuntu 安装谷歌

    下载ubuntugoogle官网:http://www.ubuntuchrome.com/ 我的是ubuntuLTS稳定版: 上传Ubuntu: 执行解压操作: sudo   dpkg -i  goo ...

  6. 数据库 concat 与 ||

    mysql中用concat,oracle中concat和||都有,都是做字符串拼接的 oracle简单实例: 1.建表 CREATE TABLE tab1 (col1 VARCHAR2(6), col ...

  7. Git 添加远程github仓库的时候提示错误:fatal: remote origin already exists.

    1.先删除远程 Git 仓库 $ git remote rm origin 2.再添加远程 Git 仓库 $ git remote add origin git@github.com:wsydxian ...

  8. jvm(5):类加载机制

    类加载时机 Java虚拟机规范并没有强制约束类加载过程的第一个阶段时机,但对初始化阶段由严格规定5中必须立即对类进行初始化的情况: 遇到new.getstatic.putstatic或invokest ...

  9. django 模型增加字段后迁移失败

    任      务:已有models.py文件中定义了 ad类(用来描述广告数据库表结构).现在想增加四个新字段:ad_show_type,big_video_url,is_full_screen,vi ...

  10. js设计模式之实现观察者模式实例代码

    前端界面 html代码 <body> <select name="" id="select"> <option value=&qu ...