You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/TangDou/AcWing/DP/ConvexHullTrick/【学习笔记】四边形不等式.md

2.1 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

【四边形不等式】

前言

四边形不等式 是一种 动态规划优化 方法,通过对 决策单调性 的证明及应用,使得总体复杂度 降低一个数量级 。目前我见过的四边形不等式的题目不多,且大多数比较裸。四边形不等式的常见模型及其基础应用并不难,难点在于与四边形不等式相关的证明,尤其是题目中出现以前没有见过的转移方程的时候。由于本人数学很渣,所以问了很多大神,尝试了各种方法绕过证明。这里把我的经验分享给大家,尤其是像我一样的数学不好的同学。所以,本文并没有证明相关的东西,如果大家想看证明,可以阅读赵爽的文章《动态规划加速原理之四边形不等式》,百度文库上应该有免费下载。

一种基本形式

四边形不等式的基本形式非常简单,用于常见的区间dp的优化。

转移方程形式为

\large f[i][j] = min\{f[i][k] + f[k+1][j] + w(i,j)\}~~i <= k < j

这个方程大家再熟悉不过了,长区间 可以从 短区间 转移过来,w(i,j)表示将闭区间[i,j]合并产生的费用,状态有O(n^2)个,每个状态的决策有O(n)个,总复杂度为O(n^3)

现在用 四边形不等式 对其优化,首先需要知道什么是 四边形不等式

若函数w(i,j)满足w(a,c) + w(b,d) <= w(a,d) + w(b,c),其中a <= b < c <= d,则称w 满足四边形不等式

可以看做一个以(a,c)左上角(b,d)右下角 的矩阵中,左上角 的值 加上 右下角的值小于 左下角 的值加上 右上角 的值。注意我们要求b < c,因为在实际的区间问题中,既然w(b,c)表示合并区间[b,c]的费用,那么b一定是小于等于c的。在这个限制下,如果把我们所有的状态写成一个矩阵的话,有用的状态一定是行号小于等于列号的,即所有有用的状态f[i][j]中,i <= j

挖坑待填 2022-09-30

【教程】四边形不等式学习笔记