题解 Hero meet devil】的更多相关文章

题目传送门 题目大意 给出一个长度为 \(n\) 的字符串,对于每个 \(k\in [0,n]\),求出有多少个长度为 \(m\) 的字符串满足两者最长公共子序列长度为 \(k\). \(n\le 15,m\le 10^3\),答案对 \(10^9+7\) 取模. 思路 难得扣shi... 首先,我们发现如果对两个已知字符串求最长公共子序列,那么我们可以设 \(f_{i,j}\) 表示第 1 个字符串匹配到 \(i\),第 2 个字符串匹配到 \(j\) 的最长匹配长度.不难得到转移式: \[f…
[BZOJ3864]Hero meet devil Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in lo…
3864: Hero meet devil 题意: 给你一个只由AGCT组成的字符串S (|S| ≤ 15),对于每个0 ≤ .. ≤ |S|,问 有多少个只由AGCT组成的长度为m(1 ≤ m ≤ 1000)的字符串T,使得\(LCS(T,S) = i\)? dp套dp! 通过一个外层的dp来计算使得另一个dp方程(子dp)最终结果为特定值的输入数. 一位一位确定子dp的输入,记录子dp的状态值 子dp: \(d(i,j)\)表示\(LCS(T[1,i],S[1,j])\),对第二维差分,\(…
题目链接 BZOJ 3864 题意简述 设字符集为ATCG,给出一个长为\(n(n \le 15)\)的字符串\(A\),问有多少长度为\(m(m \le 1000)\)的字符串\(B\)与\(A\)的最长公共子序列为\(i\),对所有\(0 \le i \le n\)输出答案. 题解 传说中的计算机理论科科科科科学家cls的DP套DP. 因为看别人写的题解我都看不懂--所以我在这篇题解中,换一种方式讲解,从暴力一点点优化得到DP套DP,应该更容易理解. 暴力怎么写呢?显然是枚举所有可能的字符串…
https://www.lydsy.com/JudgeOnline/problem.php?id=3864 http://acm.hdu.edu.cn/showproblem.php?pid=4899 给你字符集为{A,T,G,C}的字符串,问有多少长度为m的字符串,满足其最长公共子序列长度为0,1……|S|. 太神啦,看巨佬博客吧:https://www.cnblogs.com/RabbitHu/p/BZOJ3864.html #include<cmath> #include<queu…
Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refuse any re…
Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refus…
Time Limit: 8 Sec  Memory Limit: 128 MBSubmit: 397  Solved: 206[Submit][Status][Discuss] Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be…
Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can't refuse any re…
题面 给你一个只由\(AGCT\)组成的字符串\(S (|S| ≤ 15)\),对于每个\(0 ≤ .. ≤ |S|\),问 有多少个只由\(AGCT\)组成的长度为\(m(1 ≤ m ≤ 1000)\)的字符串\(T\),使得\(LCS(T,S)=i\)? 题解 老早就听说这个叫做\(dp\ of\ dp\)的神仙了--然而一直没学-- 我们先考虑\(LCS\)是怎么转移的,设\(LCS(i,j)\)表示第一个串到\(i\),第二个串到\(j\)为止的最长公共子序列,那么转移为 \[ LCS(…