usaco-Section 2.4-Bessie Come Home
2016-01-24 18:55
393 查看
Bessie Come Home
Kolstad & Burch
It's dinner time, and the cows are out in their separate pastures. Farmer John rings the bell so they will start walking to the barn. Your job is to figure out which one cow gets to the barn first (the supplied test data will always have exactly one fastest cow).
Between milkings, each cow is located in her own pasture, though some pastures have no cows in them. Each pasture is connected by a path to one or more other pastures (potentially including itself). Sometimes, two (potentially self-same) pastures are connected by more than one path. One or more of the pastures has a path to the barn. Thus, all cows have a path to the barn and they always know the shortest path. Of course, cows can go either direction on a path and they all walk at the same speed.
The pastures are labeled `a'..`z' and `A'..`Y'. One cow is in each pasture labeled with a capital letter. No cow is in a pasture labeled with a lower case letter. The barn's label is `Z'; no cows are in the barn, though.
Kolstad & Burch
It's dinner time, and the cows are out in their separate pastures. Farmer John rings the bell so they will start walking to the barn. Your job is to figure out which one cow gets to the barn first (the supplied test data will always have exactly one fastest cow).
Between milkings, each cow is located in her own pasture, though some pastures have no cows in them. Each pasture is connected by a path to one or more other pastures (potentially including itself). Sometimes, two (potentially self-same) pastures are connected by more than one path. One or more of the pastures has a path to the barn. Thus, all cows have a path to the barn and they always know the shortest path. Of course, cows can go either direction on a path and they all walk at the same speed.
The pastures are labeled `a'..`z' and `A'..`Y'. One cow is in each pasture labeled with a capital letter. No cow is in a pasture labeled with a lower case letter. The barn's label is `Z'; no cows are in the barn, though.
PROGRAM NAME: comehome
INPUT FORMAT
Line 1: | Integer P (1 <= P <= 10000) the number of paths that interconnect the pastures (and the barn) |
Line 2..P+1: | Space separated, two letters and an integer: the names of the interconnected pastures/barn and the distance between them (1 <= distance <= 1000) |
SAMPLE INPUT (file comehome.in)
5 A d 6 B d 3 C e 9 d Z 8 e Z 3
OUTPUT FORMAT
A single line containing two items: the capital letter name of the pasture of the cow that arrives first back at the barn, the length of the path followed by that cow.SAMPLE OUTPUT (file comehome.out)
B 11 一道裸裸的 dijkstra,但是要注意细节
相关文章推荐
- 由子网掩码字符串转换成长度前缀的代码示例
- [BZOJ3262] 陌上花开
- Java字符转C的思路
- JNI类型映射
- 深入理解HTTP Session
- Adapter基类抽象(一)
- 浅谈初次搭建nginx+php+mysql遇到的问题
- apk安装与卸载
- FFMpeg将YUV转码为H264
- 通讯录-数据库SQLite的存储 数据库语言的模糊查询
- Numpy攻略系列:高级索引机制之位置列表型索引,布尔型索引
- Androidx学习笔记(22)-- 动态创建TextView展示数据库的数据
- usaco-Section 2.4-Fractions to Decimals
- REACT框架
- 今天开 CSDN 博客
- Android系统进程间通信Binder机制在应用程序框架层的Java接口源代码分析
- C++11 浅谈 右值引用和move语义
- 学习aiax(javascript)--省份-城市二级下拉联动(POST方式)
- jdk、Tomcat的安装及配置
- 触摸事件总结