A girl can organize a box. The location of the box cannot be changed. She can take two or one luggage at a time. The time spent on moving a girl is the square of her distance.
Practice: Status compression DP is still not familiar with it. You only need to take a look at the blog.
/****** Division status. This type of question is always intended for use by DFS, but I don't know how to use DFS... So observe and find that there are only 24 items. You can take two items for each item, but when you take the second item, there is only one such disturbance due to the previous state. So, compress the status. In fact, this status can ignore the order of getting things. In fact, this status can ignore the order of getting things, so we can assume that I + 1 can be obtained after I is taken, as a result, the option to take the second item for the I + 1 item does not have any damage, but the status can be updated. Each time an item is calculated, two states can be added, one or two. The new State cannot be considered as the original state... By a CF God ***/# include <cstdio> # include <cstring> # include <iostream> using namespace STD; const int LMT = 1 <24; int DP [LMT], pre [LMT], Gra [26] [26], X [26], Y [26], ANS [60]; int main (void) {int N, x0, y0; CIN> x0> y0; CIN> N; For (INT I = 0; I <n; I ++) cin> X [I]> Y [I]; X [N] = x0; y [N] = y0; For (INT I = 0; I <= N; I ++) for (Int J = I + 1; j <= N; j ++) gra [I] [J] = gra [J] [I] = (X [I]-X [J]) * (X [I]-X [J]) + (Y [I]-y [J]) * (Y [I]-y [J]); memset (DP,-1, sizeof (DP )); DP [0] = 0; For (INT I = 0; I <1 <n; I ++) if (DP [I]! =-1) {for (Int J = 0; j <n; j ++) if (! (1 <j) & I) {int T = I | (1 <j ), TEM = DP [I] + 2 * gra [J] [N]; If (DP [T] =-1 | DP [T]> TEM) {DP [T] = TEM; Pre [T] = I;} For (int K = 0; k <n; k ++) // only in this status, if (! (T & (1 <k) {int t2 = T | (1 <K ), TEM = DP [I] + gra [N] [J] + gra [J] [k] + gra [k] [N]; if (DP [T2] =-1 | DP [T2]> TEM) {DP [T2] = TEM; Pre [T2] = I ;}} break ;}} int x = (1 <n)-1, PR, TEM, A, B, CNT = 0; cout <DP [x] <Endl; while (X) {Pr = pre [X]; TEM = Pr ^ X; a = B = 0; For (INT I = 0; I <n; I ++) if (1 <I) & TEM) {B = A; A = I + 1;} ans [CNT ++] = 0; ans [CNT ++] = A; If (B) ans [CNT ++] = B; X = Pr;} ans [CNT ++] = 0; for (INT I = cnt-1; I> = 0; I --) printf ("% d", ANS [I]); printf ("\ n"); Return 0 ;}