UVA 11374-airport Express
Topic links
Test instructions: Given some economic lines, and some business lines, the business line sits at most once, each line has a time, ask the shortest time
Ideas: From the beginning, the end of each to do a dijstra, and then enumerate the business line, you can calculate the total time, and finally find the total time minimum
Code:
#include <cstdio> #include <cstring> #include <vector> #include <queue>using namespace std;# Define INF 0x3f3f3f3fconst int maxnode = 505;struct Edge {int u, V, Dist; Edge () {}edge (int u, int v, int dist) {this->u = U;this->v = V;this->dist = dist;}}; struct Heapnode {int d, u; Heapnode () {}heapnode (int d, int u) {this->d = D;this->u = u;} BOOL operator < (const heapnode& c) Const {return d > c.d;}}; struct Dijkstra {int n, m;vector<edge> edges;vector<int> g[maxnode];bool done[maxnode];int D[MAXNODE], p[ maxnode];void init (int tot) {n = tot;for (int i = 0; i < n; i++) g[i].clear (); Edges.clear ();} void Add_edge (int u, int v, int dist) {edges.push_back (Edge (U, V, Dist)); m = Edges.size (); G[u].push_back (m-1);} void print (int s, int e) {//shun Xuif (s = = e) {printf ("%d", E + 1); return;} Print (S, edges[p[e]].u);p rintf ("%d", E + 1);} void Print2 (int s, int e) {//ni Xuif (s = = e) {printf ("%d\n", E + 1); return;} printf ("%d", E + 1);p Rint2 (S, EDGES[P[E]].U);} void Dijkstra (int s) {priority_queue
UVA 11374-airport Express (Dijstra)