The basic pressure DP needs to be noted that the shortest line between two points does not need to be Floyd
Due to the DP Memset placed in the initialization of 0 after the de for a long time the bug.
#include <stdio.h> #include <string.h> #include <algorithm> #include <math.h> #include <map >using namespace std; #define EQS 0.000000001struct node{double x; Double y;}; Node a[20];d ouble f[20][20];d ouble dp[1<<17][20];int main () {int t;scanf ("%d", &t), while (t--) {int n; scanf ("%d", &n); memset (F,0,sizeof (f)); for (int i=0;i<n;i++) {scanf ("%lf%lf", &a[i].x,&a[i].y); } for (int i=0;i<n;i++) {for (int k=0;k<n;k++) {f[i][k]=f[k][i]=sqrt (a[i].x-a[k].x) * (a[i].x-a[k].x) + (A[I].Y-A[K].Y) * (A[I].Y-A[K].Y)); }} int l= (1<<n)-1; Memset (Dp,0x7f,sizeof (DP)); for (int i=0;i<n;i++) {dp[1<<i][i]=0; } for (int s=0;s<=l;s++) {for (int i=0;i<n;i++) {if ((s& (1<<i)) ==0) Continue for (int k=0;k<n;k++) {if ((s& (1<<k))!=0) continue; dp[s+ (1<<k)][k]=min (dp[s+ (1<<k)][k],dp[s][i]+f[i][k]); }}} double ans=1e300; for (int i=0;i<n;i++) {ans=min (Dp[l][i],ans); } printf ("%.2f\n", ans);}}
HLG 2130-Shape pressure DP