CSU 1527 Bounty Hunter dp bi-tune Traveler

Source: Internet
Author: User

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

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.