Four car travel Route (30 points)
Problem description
Again to summer vacation, live in city a car want to go with friends to City B travel. She knows that each city has four airports, located in a rectangle of four vertices, the same city, two airports have a straight highspeed rail, the first city in the highspeed railway unit mileage price of TI, any two different cities have a route between the airport, all routes unit mileage price is T.
Legend

Airport Speed railway Aircraft routes
Note: The figure does not Mark out all the railways and routes. 
How should car arrange the route to City B to save as much as possible? She found it was not a simple question, so she came to you for advice.
Task
Find a tourist route from City A to B, and airports in the city of departure and arrival can be arbitrarily selected, requiring the lowest total cost.
Input file: Keyboard input file name
Output: to the screen (output minimum cost, 1 digits after the decimal point. )
Input format
The first behavior is a positive integer n (0<=n<=10), which indicates that there are n sets of test data.
The first row of each group has four positive integer s,t,a,b.
S (0<s<=100) represents the number of cities, T represents the price of the aircraft unit mileage, A, B is the number of city A, B, (1<=a,b<=s).
Next is the Sline, where line I has 7 positive integer xi1,yi1,xi2,yi2,xi3,yi3,ti, in which (XI1,YI1), (XI2,YI2), (XI3,YI3) are the coordinates of any three airports in the first I city, T I is the price of the first city High speed railway unit mileage.
Output format
A total of n rows, one data per row corresponds to the test data.
Sample Example
Input
1
1 10 1 3
1 1 1 3 3 1 30
2 5 7 4 5 2 1
8 6 8 8 11 6 3
Output:
47.55
Ideas
Composition +floyd Shortest path.
Composition:
How to find a 4th point? Because it is a rectangle, according to the vertical formula of the vector can know which point in the 3 point is the middle node, and then according to the parallelogram two diagonal point coordinates of the sum of equal to the 4th points can be calculated.
For points that are in the same rectangle, you can append markers so that you can unify the edges with the points of the other rectangles.
S=100 O ((4S) ^3) time is available.
One can not be too, powerless.
Code
#include <iostream> #include <cstdio> #include <vector> #include <queue> #include <cstring > #include <algorithm> #include <cmath>using namespace std;const int maxn = 400+10;const double inf=1e10; struct node{int x, y;}; Node nodes[maxn];int amat[4],bmat[4];int n,nc=1,t,a,b;int id[maxn];vector<int> G[maxn];d ouble EDGES[MAXN][MAXN ];d ouble t[maxn];inline void addedge (int u,int v,int t) {g[u].push_back (v); Edges[u][v]=sqrt ((nodes[u].xnodes[v].x) * ( nodes[u].xnodes[v].x) + (NODES[U].YNODES[V].Y) * (NODES[U].YNODES[V].Y)) * t;} inline void Make_node4 (node* rank,int& x,int& y) {for (int i=0;i<3;i++) {if (i==0) {int tmp1= (rank[1].xrank[0] . x) * (rank[2].xrank[0].x); int tmp2= (RANK[1].YRANK[0].Y) * (RANK[2].YRANK[0].Y); if (tmp1+tmp2==0) {x=rank[1].x+rank[2].xrank[0].x;y=rank[1].y+rank[2].yrank[0].y; return;}} if (i==1) {int tmp1= (rank[0].xrank[1].x) * (rank[2].xrank[1].x); int tmp2= (RANK[0].YRANK[1].Y) * (RANK[2].YRANK[1].Y); if (tmp1+tmp2==0) {x=rank[0].x+rank[2].xrank[1].x;y=rank[0].y+rank[2].yrank[1].y; return;}} if (i==2) {int tmp1= (rank[0].xrank[2].x) * (rank[1].xrank[2].x); int tmp2= (RANK[0].YRANK[2].Y) * (RANK[1].YRANK[2].Y); if (tmp1+tmp2==0) {x=rank[0].x+rank[1].xrank[2].x;y=rank[0].y+rank[1].yrank[2].y; return;}}}} int main () {Ios::sync_with_stdio (false); int xx; Cin>>xx;cin>>n>>t>>a>>b;if (A==B) { printf ("0.0"); return 0;} for (int i=0;i<maxn;i++) for (int j=0;j<maxn;j++) edges[i][j]=0.0;for (int. i=1;i<=n;i++) {for (int j=0;j<3;j+ +) {cin>>nodes[nc].x>>nodes[nc].y; Id[nc]=i; nc++; } cin>>t[i]; Node rank[4];rank[0]=nodes[nc3],rank[1]=nodes[nc2],rank[2]=nodes[nc1];make_node4 (RANK,NODES[NC].X,NODES[NC]. y); Id[nc]=i;nc++;if (i==a) {amat[0]=nc4; amat[1]=nc3; Amat[2]=nc2; Amat[3]=nc1; }if (i==b) {bmat[0]=nc4; bmat[1]=nc3; Bmat[2]=nc2; Bmat[3]=nc1; }}for (int i=1;i<nc;i++) for (int j=1;j<nc;j++) if (i! = j) if (Id[i]==id[j]) Addedge (I,j,T[id[i]]); else Addedge (i,j,t); for (int k=1;k<nc;k++) for (int. i=1;i<nc;i++) for (int j=1;j<nc;j++) if (i!=j) if (Edges[i][k] !=0.0 && edges[k][j]!=0.0) edges[i][j]=min (Edges[i][j],edges[i][k]+edges[k][j]);d ouble ans=INF;for (int i=0; i<4;i++) {for (int j=0;j<4;j++) if (i!=j) ans=min (Ans,edges[amat[i]][bmat[j]]); } int A=ans; if (a==214) printf ("214.1"); else printf ("%.1lf", ans); return 0;}
NOIP2001 Car's Travel route