UVALive 4394 String painter】的更多相关文章

其实这个dp过程有点似懂非懂...代码如下: #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; + ; char a[N],b[N]; int dp[N][N]; int f[N]; int main() { ) == ) { ); scanf(); ;i<=n;i++) dp[i][i] = ; ;len<=n;len++) { ;i+len-&…
这题搞了很久很久..弄得我都不想放上来了,但是想了想还是写上来吧,万一以后忘了怎么做了,又得搞很久很久了.题目是要求把一个字符串变成另外一个,每次可以选择一段字符串变成同一个字符,问最少用变多少次.本来想的更复杂,写了半天一直wa,后来发现自己想错了,,一不小心看到了kuangbin大牛说可以先由空串转化成b串.然后我想了一下,发现的确可以这样,这样就可以在由空串转化成b串的基础上判断a串与b串的区别,然后就可以得到由a串转化成b串的ans了.但是由空串转化成b串的时候假如b串是:acbdaef…
// uva live 4394 String painter // // 问题是,在培训指导dp运动主题,乍一看,我以为只是一点点复杂 // A A磕磕磕,两个半小时后,.发现超过例子.然而,鉴于他们跪在数据 // 还要wa.才发现,自己的方法是有问题的,假设是将两个串同一时候考虑 // 的话.比方: dp[i][j] 表示从i到j,s串刷成目标b串所须要的最小的花费 // 然后依据区间的端点的字符特点,进行状态转移.然而可能是我太搓了. // 发现这种状态转移是不正确的,比方edc和cde.…
// uva live 4394 String painter // // 这一题是训练指南上dp专题的习题,初看之下认为仅仅是稍微复杂了一点 // 就敲阿敲阿敲,两个半小时后,发现例子过了.然而自己给出的数据跪了 // 交了也wa了,才发现,自己的方法是有问题的,假设是将两个串同一时候考虑 // 的话,比方: dp[i][j] 表示从i到j,s串刷成目标b串所须要的最小的花费 // 然后依据区间的端点的字符特点,进行状态转移,然而可能是我太搓了, // 发现这种状态转移是不正确的.比方edc和…
区间dp,两个str一起考虑很难转移. 看了别人题解以后才知道是做两次dp. dp1.str1最坏情况下和str2完全不相同,相当于从空白串开始刷. 对于一个区间,有两种刷法,一起刷,或者分开来刷. 规定[i][i-1]为空串,这样一起刷可以归结为第二种情况. 合并的时候,大的区间的次数<=小的区间的,和新加入区间的字符有关. 小的区间是一个字符一个字符的变成大区间的. 所以每次考虑新加入区间的尾部字符j,枚举k划分区间[i][k-1],[k][j]. 要使得刷的次数减少,只有尽量一起刷.比如a…
String painter Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2520    Accepted Submission(s): 1134 Problem Description There are two strings A and B with equal length. Both strings are made up…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2476 Problem Description There are two strings A and B with equal length. Both strings are made up of lower case letters. Now you have a powerful string painter. With the help of the painter, you c…
String painter Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2792 Accepted Submission(s): 1272 Problem Description There are two strings A and B with equal length. Both strings are made up of lo…
题意 String painter Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6669    Accepted Submission(s): 3230 Problem Description There are two strings A and B with equal length. Both strings are made…
题目: Problem Description There are two strings A and B with equal length. Both strings are made up of lower case letters. Now you have a powerful string painter. With the help of the painter, you can change a segment of characters of a string to any o…