1000. Campus
来源:互联网 发布:touch炫舞刷vip软件 编辑:程序博客网 时间:2024/05/18 15:53
At present, Zhongshan University has 4 campuses with a total area of 6.17 square kilometers sitting respectively on both sides of the Pearl River or facing the South China Sea. The Guangzhou South Campus covers an area of 1.17 square kilometers, the North Campus covers an area of 0.39 square kilometers, the Guangzhou East Campus has an area of 1.13 square kilometers and the Zhuhai Campus covers an area of 3.48 square kilometers. All campuses have exuberance of green trees, abundance of lawns and beautiful sceneries, and are ideal for molding the temperaments, studying and doing research.
Sometime, the professors and students have to go from one place to another place in one campus or between campuses. They want to find the shortest path between their source place S and target place T. Can you help them?
The first line of the input is a positive integer C. C is the number of test cases followed. In each test case, the first line is a positive integer N (0<N<=100) that represents the number of roads. After that, N lines follow. The i-th(1<=i<=N) line contains two strings Si, Ti and one integer Di (0<=Di<=100). It means that there is a road whose length is Di between Si and Ti. Finally, there are two strings S and T, you have to find the shortest path between S and T. S, T, Si(1<=i<=N) and Ti(1<=i<=N) are all given in the following format: str_Campus.str_Place. str_Campus represents the name of the campus, and str_Place represents the place in str_Campus. str_Campus is "North", "South", "East" or "Zhuhai". str_Place is a string which has less than one hundred lowercase characters from "a-z". You can assume that there is at most one road directly between any two places.
The output of the program should consist of C lines, one line for each test case. For each test case, the output is a single line containing one integer. If there is a path between S and T, output the length of the shortest path between them. Otherwise just output "-1" (without quotation mark). No redundant spaces are needed.
12South.xiaolitang South.xiongdelong 2South.xiongdelong Zhuhai.liyuan 100South.xiongdelong South.xiaolitang
2
Problem Source: ZSUACM Team Member
- 1000. Campus
- Campus
- In Campus
- Campus cluster
- 1031. Campus
- Campus Address
- 1031. Campus
- Sicily1031. Campus
- 1031. Campus
- No1031.Campus
- Mobile Campus客户端源代码
- Mobile Campus服务端源代码
- life on the campus
- Our College Campus
- Sicily 1031. Campus
- 10397 - Connect the Campus
- Sicily 1031. Campus
- bjtuOJ1018 Campus Singing Competition
- 题目1167:数组排序
- iOS中单例的总结
- 1004. Academy Awards
- 求给定数组中最大值和其在数组中的索引并输出
- 更改Chrome Developer Tools的字体
- 1000. Campus
- 面向对象编程中的聚合与耦合
- MFC 网络编程
- 1001. Robot
- hibernate.current_session_context_class
- 1002. Highways
- Java Socket常见异常处理
- xcode5设置LaunchImage
- 2014年MCM美国大学生数学建模——From my perspective