题解:
dp+计算几何
F[i][j]表示第i-j条边的答案
然后转移一下
代码:
#include<bits/stdc++.h> using namespace std; struct note{int x,y;}a[55]; int T,n,f[55][55]; int xot(note a,note b){return a.x*b.y-b.x*a.y;} int cal(note a,note b,note c) { return abs(xot(a,b)+xot(b,c)+xot(c,a)); } int area(int l,int r) { int s=xot(a[r],a[l]); for (int i=l;i<r;i++)s+=xot(a[i],a[i+1]); return abs(s); } int check(int l,int m,int r,int s) { return s+area(l,m)+area(m,r)==area(l,r); } int deal(int l,int r) { if (f[l][r]>=0) return f[l][r]; if (l==r||l+1==r) return f[l][r]=0; int res=200000000; if (l+2==r)return f[l][r]=cal(a[l],a[l+1],a[r]); for (int i=l+1;i<r;i++) { int s=cal(a[l],a[i],a[r]); if (!check(l,i,r,s)) continue; int z=max(deal(l,i),deal(i,r)); z=max(z,s);res=min(res,z); } return f[l][r]=res; } int main() { scanf("%d",&T); while (T--) { scanf("%d",&n); memset(f,255,sizeof(f)); for (int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y); printf("%.1lf\n",deal(1,n)/2.0); } return 0; }