随笔分类 -  ACM / 字符串

摘要:难点:字符串处理 #include <iostream> #include <cstring> #include <cstdio> #include <map> using namespace std; char ss[100],s1[50],s2[50]; string s3; map<strin 阅读全文
posted @ 2020-04-22 20:38 Hazelxcf 阅读(108) 评论(0) 推荐(0)
摘要:KMP next数组:next[i]表示以i为终点的前缀的最长相同前后缀长度 拓展KMP extend数组: extend[i]表示文本串T中以i为起点的后缀与模式串S的最大相同前缀的长度 next数组:next[i]表示S以i为终点的最大相同前后缀长度 阅读全文
posted @ 2020-04-21 08:34 Hazelxcf 阅读(67) 评论(0) 推荐(0)
摘要:题意:给你n个由小写字母组成的字符串S,求出能找到k个S的新字符串,并且尽量短 考察nxt数组的含义 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; 阅读全文
posted @ 2020-04-21 08:23 Hazelxcf 阅读(128) 评论(0) 推荐(0)
摘要:题意:给出一个字符串,问字符串中存在多少子串,使得这些子串既是字符串的前缀,又是字符串的后缀,要求从小到大依次输出这些子串的长度。 思路:根据 next 数组的定义,可以得到前缀 next[len] 长度的子串与后缀 next[len] 长度的子串相同,因此求出 len 处的 next 值,然后向下 阅读全文
posted @ 2020-04-21 08:00 Hazelxcf 阅读(143) 评论(0) 推荐(0)
摘要:样例输 3 ba a aba 样例输出复制 2 3 1 #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <cstdio> #include <map> using namesp 阅读全文
posted @ 2020-04-16 21:34 Hazelxcf 阅读(163) 评论(0) 推荐(0)
摘要:It's easy to tell if two words are identical - just check the letters. But how do you tell if two words are almost identical? And how close is "almost 阅读全文
posted @ 2020-04-16 21:20 Hazelxcf 阅读(197) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 100001; string str; int s,sj,g; int ans; signed main(){ ios::sync_ 阅读全文
posted @ 2020-04-03 20:39 Hazelxcf 阅读(184) 评论(0) 推荐(0)
摘要:https://www.luogu.com.cn/problem/P2444 直接AC自动机即可。建完后,跑一边AC机,看一下能不能跑出一个不经过病毒,并且循环的字符串。 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 const int 阅读全文
posted @ 2020-03-20 20:32 Hazelxcf 阅读(182) 评论(0) 推荐(0)
摘要:https://www.bilibili.com/video/av90385531?from=search&seid=11790479184604279961 阅读全文
posted @ 2020-03-10 20:44 Hazelxcf 阅读(80) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/143/ #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; char a[maxn]; int n,t; int nxt[max 阅读全文
posted @ 2020-03-10 20:38 Hazelxcf 阅读(95) 评论(0) 推荐(0)
摘要:小七是一个很可爱很努力的女孩子。她对大数的运算非常感兴趣,在学习了几天之后,终于精通了大数的加减乘除。但是自从她学会了 JAVA ,她觉得大数实在是太简单太无聊了,因为运用 JAVA 中 BigInteger 大整数类,可以轻松实现大数的加减乘除。某一天她突然发现,很多大数的题目的数据都有规律。这些 阅读全文
posted @ 2020-03-10 18:03 Hazelxcf 阅读(255) 评论(0) 推荐(0)
摘要:大佬的博客 https://www.cnblogs.com/hyfhaha/p/10802604.html P3808 【模板】AC自动机(简单版) https://www.luogu.com.cn/problem/P3808 #include<bits/stdc++.h> #define maxn 阅读全文
posted @ 2020-03-04 15:55 Hazelxcf 阅读(150) 评论(0) 推荐(0)
摘要:https://www.luogu.com.cn/problem/P2580 #include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; int n,m; string s; int num; struct node 阅读全文
posted @ 2020-03-03 20:28 Hazelxcf 阅读(116) 评论(0) 推荐(0)
摘要:hash好像可以暴力水过很多字符串算法 1、kmp 问题:给两个字符串S1,S2,求S2是否是S1的子串,并求S2在S1中出现的次数 把S2 Hash出来,在S1里找所有长度为|S2| 2、AC自动机 问题:给N个单词串,和一个文章串,求每个单词串是否是文章串的子串,并求每个单词在文章中出现的次数。 阅读全文
posted @ 2020-03-03 11:26 Hazelxcf 阅读(128) 评论(0) 推荐(0)
摘要:https://ac.nowcoder.com/acm/problem/15253 可以先把模式串拆分,计算出每部分,然后排序 读入模式串,匹配这两部分 #include <bits/stdc++.h> using namespace std; typedef long long ll; typed 阅读全文
posted @ 2020-03-02 17:59 Hazelxcf 阅读(166) 评论(0) 推荐(0)
摘要:对给定的字符串,本题要求你输出最长对称子串的长度。例如,给定Is PAT&TAP symmetric?,最长对称子串为s PAT&TAP s,于是你应该输出11。 输入格式: 输入在一行中给出长度不超过1000的非空字符串。 输出格式: 在一行中输出最长对称子串的长度。 输入样例: Is PAT&T 阅读全文
posted @ 2020-02-20 09:12 Hazelxcf 阅读(295) 评论(0) 推荐(0)
摘要:KMP https://blog.csdn.net/v_july_v/article/details/7041827 P3375 【模板】KMP字符串匹配 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 const int maxn = 1 阅读全文
posted @ 2020-02-11 10:21 Hazelxcf 阅读(136) 评论(0) 推荐(0)
摘要:给一个字符串 T,问在字符串 T 中可以包含最多多少个不重叠的字符串 S。 字符串中的每个字符为小写或者大写字母。 输入 第一行输入一个字符串 S。 第二行输入一个字符串 T。 输出 输出一行,包括一个整数表示答案。 样例输入 Copy Aba Abababa 样例输出 Copy 1 提示 50%的 阅读全文
posted @ 2020-02-05 17:10 Hazelxcf 阅读(186) 评论(0) 推荐(0)