本题正解不是玄学算法吗

P1433 吃奶酪

%%%,大佬您太强了 正解好像是状压DP ~~然而我用爆搜就水过去了~~
by dblark @ 2018-07-10 10:42:19


%%%模拟退火大佬
by UKE开车自动机 @ 2018-07-10 10:59:13


瞎写的,连这题15的数据都过不了。但是搜索不说,即使是状压DP也是2^n级别的复杂度,再大一点就没得玩了
by fly20040720 @ 2018-07-10 14:40:38


~~莫名90分~~
by SYH123456 @ 2018-08-15 11:05:51


@[Ho0eDdzVW7](/space/show?uid=27950) 我爬山A了啊
by mt19337 @ 2018-08-17 15:21:15


真奇怪 ```cpp #include<bits/stdc++.h> #define repeat(a,b,c,g) for (int a=b,abck=(g>=0?1:-1);abck*(a)<=abck*(c);a+=g) using namespace std; struct point { double x,y; }a[20]; int n; double operator - (point a,point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } double calc() { double ans=0; repeat(i,1,n,1) ans += a[i-1] - a[i]; return ans; } int main() { srand(233); cin >> n; a[0].x = 0; a[0].y = 0; repeat(i,1,n,1) { cin >> a[i].x >> a[i].y; } double MIN = calc(); repeat(_,1,1000,1) { repeat(i,1,n,1) { swap(a[rand()%n+1],a[i]); } repeat(i,1,n,1) repeat(j,i+1,n,1) { double tmp = calc(); MIN = min(tmp,MIN); swap(a[i],a[j]); double tp2 = calc(); if (tp2 > tmp) swap(a[i],a[j]); MIN = min(tp2,MIN); } } printf("%.2f",MIN); } ```
by mt19337 @ 2018-08-17 15:21:46


|