Making Huge Palindromes LightOJ - 1258】的更多相关文章

题目链接:LightOJ - 1258 1258 - Making Huge Palindromes   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A string is said to be a palindrome if it remains same when read backwards. So, 'abba', 'madam' both are palindromes, but…
Generating Palindromes LightOJ - 1033 题意:添加最少的字符使得给出的字符串成为回文串.输出添加的字符数. 方法:常规区间dp.ans[i][j]表示使得ans[i][j]成为回文串最少添加的字符数.如果i和j位置的字符相等那么ans[i][j]=ans[i+1][j-1],否则要么左边去掉一个,要么右边去掉一个,就是$min(get(l,r-1),get(l+1,r))+1$. 错误记录:和cf607b以及poj1141搞混.那两道题不需要添加字符成为回文串…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1258 就是求逆串和原串的匹配长度 答案就是原串长度的2倍减去匹配长度即可 第一次我将原串接在逆串后面然后一次求失败函数得当前串的f[len1](假设当前总串长度为len1)那么答案即为了len1-f[len1],如果f[len1]>=len ,那么答案为len 但是wrong了,,不知道原因 第二次就直接匹配原串和逆串然后就AC了 我把错误代码和正确代码都贴出来,有时间再思考为什么第…
题意 给定一个字符串 \(S\) ,一次操作可以在这个字符串的右边增加任意一个字符.求操作之后的最短字符串,满足操作结束后的字符串是回文. \(1 \leq |S| \leq 10^6\) 思路 \(\text{KMP}\) 的 \(fail\) 数组是整个算法最重要的东西,能拓展出很多东西. 对于一个模式串(pattern)\(P\) ,\(fail\) 数组为 \(f\) ,那么 \(f[i]\) 就是如果匹配到 \(i\) 这个位置失配,下次去尝试的位置,也就说明了从字符串头到 \(f[i…
题意:给定上一个串,让你在后面添加一些字符,使得这个串成为一个回文串. 析:先用manacher算法进行处理如果发现有字符匹配超过最长的了,结束匹配,答案就是该字符前面那个长度加上该串原来的长度. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include &l…
D - 楼下水题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1258 Description A string is said to be a palindrome if it remains same when read backwards. So, 'abba', 'madam' both are palindromes,…
LightOJ 1033  Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/A 题目: Description By definition palindrome is a string which is not changed when reversed. "MADAM" is a nice example of palindrome.…
B. Lovely Palindromes 题目连接: http://www.codeforces.com/contest/688/problem/B Description Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palin…
http://lightoj.com/volume_showproblem.php?problem=1213  Fantasy of a Summation Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1213 Description If you think codes, eat codes then sometimes you…
http://codeforces.com/problemset/problem/688/B B. Lovely Palindromes time limit per test 1 second memory limit per test 256 megabytes Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backw…