Travel |
Time limit:1000 MS |
Memory limit:32768 K |
Total Submit:18(6 users) |
Total Accepted:3(3 users) |
Rating: |
Special Judge: No |
|
Description |
"04.24, and Sakura to Tokyo Sky Tree, the world's warmest place on top of the sky tree. " "04.26, and Sakura to Meiji Jingu, where the wedding was held." " "04.25, and Sakura to Disney, haunted House is terrible, but there are Sakura in, so not scary." " " Sakura the best. " --Jiangnan "Dragon Clan" painted pears and Lu Mingfei today from Disney to the sky tree, but they do not have much money, so they can save the province, they now have a map on the road between the N attractions and m attractions, each road by car need a certain amount, now they turn to you, Please help them calculate the minimum amount of money required from the current location to the destination. |
Input |
There are more than one set of data, the first row of each group of data has two numbers 2<=n<=30000,1<=m<=30000. next N lines enter n place names. The next M- line has two strings ( not exceeding the length ) and a number, representing the cost of the car between the two places. the next line is to enter two strings representing the start and end points, respectively. |
Output |
an int number represents the minimum amount of money required. The data guarantee does not exceed the int type range. |
Sample Input |
2 1 Disney Tokyoskytree Disney Tokyoskytree 1 Disney Tokyoskytree |
Sample Output |
1 |
Source |
2014 Summer Training Session (July 19) See the Science and Technology topic on this topic do not have a few people, just see what is the thing! ~ #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include < string.h> #include <cctype> #include <string> #include <cmath> #include <vector> #include <stack> #include <queue> #include <map> #include <set>using namespace std;const int maxn=30003; const int Inf=0x1f1f1f1f;int n,m;//tag start position string s;string e;map<string,int>cnt;//Map to node number struct edge{int from,to, Dist Edge (int u,int v,int D): From (U), to (v), Dist (d) {}};vector<edge>edges;//node information for storage edge vector<int>g[maxn];// adjacency table bool DONE[MAXN]; Whether the tag has accessed int D[MAXN]; Distance array struct Heapnode//for precedence queue custom {int d,u; BOOL operator < (const heapnode RHS) Const {return d > rhs.d; } heapnode (int dd,int uu):d (DD), U (UU) {}};void init ()//initialization required {for (int i=0; i<n; i++) g[i].clear (); Edges.clear ();} void Addedge (int from,int to,int dist) {edges.push_back (Edge (from,to,dist)); int m = Edges.size (); G[from].push_back (m-1);} void Dij (int s) {priority_queue
|
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Harbin Polytechnic OJ 2122 Travel (map + Shortest path DIJ algorithm)