<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%2F02-%E5%8C%BA%E9%97%B4DP</id>
	<title>12-动态规划/02-区间DP - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%2F02-%E5%8C%BA%E9%97%B4DP"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;action=history"/>
	<updated>2026-05-20T22:13:02Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;diff=444&amp;oldid=prev</id>
		<title>33DAI：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;diff=444&amp;oldid=prev"/>
		<updated>2026-05-20T18:24:08Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 18:24的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l63&quot;&gt;第63行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第63行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:动态规划]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:动态规划]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:三三文档]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:三三文档]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key my_wiki:diff:1.41:old-419:rev-444:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;diff=419&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;diff=419&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:26Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 18:12的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-418:rev-419 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;diff=418&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=12-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/02-%E5%8C%BA%E9%97%B4DP&amp;diff=418&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== 区间 DP ==&lt;br /&gt;
&lt;br /&gt;
区间 DP 的状态定义为一个区间 &amp;lt;math&amp;gt;[l, r]&amp;lt;/math&amp;gt;，通过枚举区间内的分割点 &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; 来合并两个子区间。&lt;br /&gt;
&lt;br /&gt;
=== 通用模板 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// 枚举区间长度 len&lt;br /&gt;
for (int len = 2; len &amp;lt;= n; len++)&lt;br /&gt;
    for (int l = 1; l + len - 1 &amp;lt;= n; l++)&lt;br /&gt;
    {&lt;br /&gt;
        int r = l + len - 1;&lt;br /&gt;
        for (int k = l; k &amp;lt; r; k++)&lt;br /&gt;
            dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + cost(l, k, r));&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 石子合并 ==&lt;br /&gt;
&lt;br /&gt;
有 &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; 堆石子排成一排，每次合并相邻两堆，代价为两堆石子数之和，求最小总代价。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int a[MAXN], pre[MAXN], dp[MAXN][MAXN];&lt;br /&gt;
&lt;br /&gt;
memset(dp, 0x3f, sizeof dp);&lt;br /&gt;
for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
{&lt;br /&gt;
    dp[i][i] = 0;&lt;br /&gt;
    pre[i] = pre[i - 1] + a[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for (int len = 2; len &amp;lt;= n; len++)&lt;br /&gt;
    for (int l = 1; l + len - 1 &amp;lt;= n; l++)&lt;br /&gt;
    {&lt;br /&gt;
        int r = l + len - 1;&lt;br /&gt;
        int cost = pre[r] - pre[l - 1];&lt;br /&gt;
        for (int k = l; k &amp;lt; r; k++)&lt;br /&gt;
            dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + cost);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 回文串问题 ==&lt;br /&gt;
&lt;br /&gt;
求最长回文子序列：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// dp[l][r] = s[l..r] 的最长回文子序列长度&lt;br /&gt;
for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    dp[i][i] = 1;&lt;br /&gt;
&lt;br /&gt;
for (int len = 2; len &amp;lt;= n; len++)&lt;br /&gt;
    for (int l = 1; l + len - 1 &amp;lt;= n; l++)&lt;br /&gt;
    {&lt;br /&gt;
        int r = l + len - 1;&lt;br /&gt;
        if (s[l] == s[r])&lt;br /&gt;
            dp[l][r] = dp[l + 1][r - 1] + 2;&lt;br /&gt;
        else&lt;br /&gt;
            dp[l][r] = max(dp[l + 1][r], dp[l][r - 1]);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:动态规划]]&lt;br /&gt;
[[Category:三三文档]]&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>