题目:http://codeforces.com/contest/1200/problem/E Compress Words time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amugae has a sentence consisting of nn words. He want to compress this sentenc…
题意:给你一个字符串,有2种消除方式:1:消除一个单独的字母,代价为a.2:s[j]到s[k]是s[1]到s[j - 1]的子串,那么s[j]到s[k]可以消除,代价为b,问最小的代价. 思路:官方题解说的很明白了. 代码: #include <bits/stdc++.h> #define LL long long #define INF 0x3f3f3f3f using namespace std; const int maxn = 5010; int dp[maxn]; int v[max…
Description Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer…
下面是KMP算法的实现伪代码: KMP_MATCHER ( T, P ) . n = T.length . m = P.length . next = COMPUTE_PREFIX_FUNCTION ( P ) . q = //number of characters matched . to n //scan the text from left to right . and P [q+] <> T[i] //next character does not match . q = next[…
Another Meaning 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5763 Description As is known to all, in many cases, a word has two meanings. Such as "hehe", which not only means "hehe", but also means "excuse me". Today, ?? i…