UVA 1001 Diagram + Shortest circuit

Source: Internet
Author: User

Test instructions

In a three-dimensional space, the shortest time from the starting point to the end is spent.

where n holes, the time spent in the hole is 0, the time spent outside the hole is 10sec per unit


Water problem

Establish the starting point to the sides of each hole, establish the end point to the side of each hole, establish the starting point to the end of the edge, and the edge is the time spent to reach the desired point. To find the shortest possible time.


#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector    > #include <queue>using namespace std;const int maxn = 105;int n;struct ball{double x, y, Z, R;        Ball () {} ball (double x_, double y_, double z_, double r_) {x = X_;        y = y_;    z = z_;    }}BB[MAXN];d ouble sx,sy,sz,ex,ey,ez;const int INF = 0x3f3f3f3f;const int maxnode = 110;struct edge{int u, v;    Double Dist;        Edge () {} edge (int u, int v, double dist) {this->u = u;        This->v = v;    This->dist = dist;    }};struct Heapnode {int u;    Double D;        Heapnode () {} heapnode (double 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];    Double D[maxnode];    int 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, double dist) {Edges.push_back (Edge (U, V, dist));        m = Edges.size ();    G[u].push_back (m-1);        } void Dijkstra (int s) {priority_queue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.