标签:syn force air pair inf one pen run case
本题是区间dp里的三角剖分,板子题,dp[i][j]表示凸多边形i-j构成的最值,转移方程为dp[i][j] = min/max(dp[i][k]+dp[k][j]+w[i,j,k])(i<k<j),表示将凸多边形i-j以k为分界,分成i-k,k-j以及三角形i-j-k
#include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) typedef long long LL; typedef pair<int,int> pii; const LL INF = 0x3f3f3f3f3f3f3f3f; const int maxn = 505; LL dp[maxn][maxn]; void run_case() { int n; cin >> n; for(int i = n-2; i >= 1; --i) { for(int j = i+2; j <= n; ++j) { dp[i][j] = INF; for(int k = i+1; k < j; ++k) dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]+i*j*k); } } cout << dp[1][n]; } int main() { ios::sync_with_stdio(false), cin.tie(0); cout.flags(ios::fixed);cout.precision(10); //int t; cin >> t; //while(t--) run_case(); cout.flush(); return 0; }
Codeforces1140D. Minimum Triangulation
标签:syn force air pair inf one pen run case
原文地址:https://www.cnblogs.com/GRedComeT/p/12348704.html