Topic Link: Click to open the link
Naked Double-tune travel business.
#include <stdio.h> #include <string.h> #include <iostream> #include <math.h> #include <queue > #include <set> #include <algorithm> #include <stdlib.h>using namespace std; #define LL Int#define N 550#define inf 1152921504606846976struct node{double x, Y;bool operator< (const node&a) const{if (a.x==x) return A.y>y;return a.x>x;} void put () {printf ("(%.0f,%.0f) \ n", x, y);}} P[n];d ouble Dis (Node A, Node B) {return sqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y));} int n;double Dis[n][n],dp[n][n];int Main () {ll I, J, u, v; int T; scanf ("%d", &t); while (t-->0) {scanf ("%d", &n); for (i=1;i<=n;i++) scanf ("%lf%lf", &p[i].x,&p[i].y), sort (p+1,p+n+1),//for (int i = 1; I <= n; i++) P[i].put ( ); for (i=1;i<=n;i++) for (j=1;j<=n;j++) dis[i][j] = Dis (p[i],p[j]), dp[i][j] = inf;dp[1][1] = 0;for (i=2;i<=n;i++ {for (j = 1;j < I; j + +) {Dp[i][j] = min (dp[i-1][j]+dis[i][i-1], dp[i][j]);DP [i][i-1] = min (Dp[i-1][j]+dis[j][i], dp[I][i-1]);}} printf ("%.10f\n", dp[n][n-1]+dis[n][n-1]); } return 0;}
CSU 1527 Bounty Hunter dp bi-tune Traveler