
======字符串=======
文章平均质量分 74
九野的博客
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU 4706 Children's Day && 2013 ACM/ICPC Asia Regional Online —— Warmup
题意:用字母排出N这个形状mark:#include #include #include #include #include #include using namespace std; int main(){ int a[12][30][20]; int i,j,x; int l=97; for(i=3;i<=原创 2013-09-08 17:51:38 · 1703 阅读 · 0 评论 -
UVA 12378 Ball Blasting Game Manacher裸题
题目链接:点击打开链接题意:消除字符串游戏,选择一个字母,则会消除和该字母相同且连续的一段,然后左右两边合拢,若左右两边字母相同则再次消除掉。直到合拢时两边字母不相同。问这样连续消除的最大次数。思路:先把连续相同的字母当成一个字母,然后求最长回文串,则答案就是(最长长度+1)/;2#pragma comment(linker, "/STACK:1024000000,10原创 2014-12-07 00:28:04 · 17605 阅读 · 0 评论 -
Manacher模版
求字符串中出现过的最长回文子串const int MAXN = 110010;//字符串长度<MAXNchar Ma[MAXN * 2];int Mp[MAXN * 2];void Manacher(char s[]) { int l = 0, len = strlen(s); Ma[l++] = '$'; Ma[l++] = '#'; for (int i = 0; i<le原创 2014-12-07 00:17:46 · 2212 阅读 · 0 评论 -
HNU 13108 Just Another Knapsack Problem ac自动机上的dp
题目链接:点击打开链接题目链接:给定一个母串。给出n个子串和子串对应的价值用下面的n个子串拼出母串,则得到的价值为子串价值和拼接时不能有重叠遗漏(即母串的每个位置恰好被覆盖一次)在ac自动机上找的时候搞一个dp数组就好了#include#include#include#include#includeusing namespace std;const原创 2014-11-29 15:51:42 · 1254 阅读 · 0 评论 -
Codeforces 56D Changing a String 编辑距离 记忆化dp
题目链接:点击打开链接编辑距离,,== 一边dp一边记录前驱太累,,还是dp后找路径大法好#include#include#include#includeusing namespace std;#define ll int#define N 1010char s[N], t[N];int dp[N][N], n, m;// 0为插入 1为删除 2 3为替换struct原创 2014-08-04 16:17:19 · 1333 阅读 · 0 评论 -
HDU 4357 String change 规律题
题意:给定a串b串,问能否把a变成b串方法:任选a的2个字母,ascil+=1 然后交换位置,可以操作任意多次。3个及3个以上一定可以T^T2个就暴力判一下#include #include #include #include using namespace std;const int N = 66;char a[N], b[N];bool check()原创 2014-10-10 13:52:33 · 1356 阅读 · 0 评论 -
HDU 4821 String 字符串hash(水
题意:给定整数M L一个字符串s我们定义一个子串为"好"串 iff1、长度为 M*L2、把这个好串分成M段,每段长度为L,且每段各不相同。且我们得到的这些好串不重复计算(即把这些好串去重)问有几个好串#include #include #include #include using namespace std;typedef unsigne原创 2014-10-26 15:56:58 · 1627 阅读 · 0 评论 -
UVALive 5103 Computer Virus on Planet Pandora Description 求模式串出现的种数 AC自动机
题目链接:点击打开链接题意:case数n个模式串一个母串。问:n个模式串出现的种数(一个模式串多次出现只算一次)对于 "ABC" , 若母串出现了"CBA"这样的反串,也算出现了。所以:1ABCCBA ans = 1#include #include #include #include #include using namespace st原创 2014-11-10 23:52:51 · 1360 阅读 · 0 评论 -
HDU 4125 Moles 线段树+KMP
题意:给定n,下面是1-n的排列。下面一个二进制子串。先按给定的排列建出二叉树。然后遍历树(根->左子树->根->右子树->根)遍历这个节点时 若权值为奇数入栈一个1,若为偶数入栈一个0得到一个母串。问母串中出现了几次子串。思路:先是建树得到母串,然后求子串个数就是裸的KMP。建树就是找个规律,然后用线段树维护一下输入的排列#include #原创 2014-11-09 14:38:57 · 1987 阅读 · 0 评论 -
ZOJ 3818 Pretty Poem 模拟题
题目链接:点击打开链接#include #include #include #include using namespace std;const int N = 55;char a[N], b[N];int main() { int T; scanf("%d", &T); while(T-- > 0) { scanf("%s", a); int Len =原创 2014-09-07 19:03:04 · 1511 阅读 · 0 评论 -
URAL 1737 Mnemonics and Palindromes 3 构造
题目链接:点击打开链接题意:给定n#include #include #include using namespace std;char a[][4] = {"abc", "acb", "bac", "bca", "cab", "cba"};int main() { int n; while (~scanf("%d", &n)) { if(n * 6原创 2014-09-18 16:39:28 · 1364 阅读 · 0 评论 -
URAL 1732 Ministry of Truth KMP
题目链接:点击打开链接题意:给定母串a和原创 2014-09-18 16:27:54 · 1150 阅读 · 0 评论 -
ZOJ Monthly, October 2010 ABEFI
ZOJ 3406Another Very Easy Task#include #include const int N = 100005;char s[N];int main() { bool f = 0; int size = 0; char ch; while(scanf("%c", &ch)!=EOF) { if( !(ch >= 'a' && c原创 2014-07-07 23:59:26 · 1426 阅读 · 0 评论 -
2014 北京邀请赛ABDHJ题解
A:点击打开链接构造,结论是从第一行开始往下产生一条曲线,使得这条区间最长且从上到下递减,#include #include #include #include #include #include #include using namespace std;#define N 100005vectorG[N], P[N], tmp;sets[N];set::iterat原创 2014-07-03 23:27:08 · 1569 阅读 · 0 评论 -
Codeforces 39J Spelling Check hash
题目链接:点击打开链接题意:给定2个字符串选择第一个字符串的其中一个字母删除,使得2个字符串完全相同问哪些位置可以选思路:hash求前缀后缀,然后枚举位置#include #include #include#include#include #include#include#include#includeusing namespace std;原创 2014-07-16 17:06:05 · 1989 阅读 · 0 评论 -
UVa 11732 统计使用strcmp()两两比较字符串的总次数 字典树
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=2832&mosmsg=Submission+received+with+ID+13213761P210注意:字符串的量非常大,用二维的字典树会爆内存(但开到极限会影响速度原创 2014-02-26 01:22:11 · 2047 阅读 · 0 评论 -
Codeforces 536B Tavas and Malekas 求自身首尾的重叠位置 KMP
题目链接:点击打开链接题意:用小写字母构造n长的串S,m个要求字符串P下面m个位置。a1, a2···am(输入有序)要使得字符串S的以ai 开头且后面是一个P串。问构造的方法数思路:实际上,对于ai, ai+1 ,两个位置,如果这两个位置会相互影响(即 ai+1 - ai 复制一个和P一样的串P‘把P放在ai位置,把P‘放在ai+1位置,那么只需要判断一下原创 2015-04-15 13:57:08 · 1594 阅读 · 0 评论