动态规划模型整理

最长公共子序列(LCS)

\(f_{i, j} : a_{1 \sim i}, b_{1 \sim j}\) 的 \(LCS\),不强制 \(a_i = b_j\)。

	F(i, 1, n){
		F(j, 1, m){
			f[i][j] = max(f[i][j - 1], f[i - 1][j]);
			if(s[i] == t[j]) f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
		}
	}

练习:Problem - 2242D - Codeforces

posted @ 2026-09-06 20:45  superl61  阅读(8)  评论(0)    收藏  举报