"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 Shrine. There was a wedding held there. " "04.25. and Sakura to Disney. Haunted House is very scary. 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 is required to ride a certain amount, and now they turn to you, Please help them calculate the minimum amount of money required from the current location to the destination. |
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. |
2014 Summer Training Session (July 19) There are not many people who have seen the topic on science and technology. Let's see what it is! ~ #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]; Mark whether to interview int D[MAXN]; Distance array struct Heapnode//for precedence queue own definition {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 indispensable {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
|