題目中有乙個蛋糕,要求盡可能的分割蛋糕,並且每乙個對角線的切割都有一定的消費,要求計算消費最小,並且如果這個多邊形不滿足凸包,直接輸出"i can't cut."
題目相對於最優三角劃分,只是多了乙個凸包的判斷,並且這也就是乙個模板題目,可以直接使用graham掃瞄法的模板計算,然後如果是凸包,那麼再去計算最優的劃分消耗
#include #include #include #include #include #include #include #define inf 0x3f3f3f3f
using namespace std;
const int maxn = 350;
int n,m;
struct point
p[maxn],c[maxn];
int cost[maxn][maxn],dp[maxn][maxn];
int mulit(point p0, point p1, point p2)
double dis(point a,point b)
bool cmp(point a,point b)
int get_cost(point a,point b)
int graham()
return tot;
}int main()
printf("%d\n",dp[0][n-1]);}}
return 0;
}
zoj 3537 Cake (凸包 最優三角剖分)
題目鏈結 這道題目是一道最優三角剖分的題目,其實也是一種區間dp裡的一種應用,思路也很簡單。這道題目還需要先判斷是不是凸包,這裡其實主要想記錄一下凸包模板 include include include include include using namespace std const double...
凸三角形最優三角剖分
1 凸多邊形的三角剖分 將凸多邊形分割成互不相交的三角形的弦的集合t。2 最優剖分 給定凸多邊形p,以及定義在由多邊形的邊和弦組成的三角形上的權函式w。要求確定該凸多邊形的三角剖分,使得該三角剖分中諸三角形上權之和為最小。下圖為剖分案例。若凸 n 1 邊形p 的最優三角剖分t包含三角形v0vkvn,...
dp 最優三角剖分問題
額,基本和演算法分析上的差不多,只是更加了解dp的狀態吧 include include include include include includeusing namespace std define max 100 int n int t max max s max max int value...