
字符串
文章平均质量分 71
天翼之城*
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Codeforces 1466 G. Song of the Sirens —— kmp,想法,有丶东西
This way题意:给你串s0和t,t的长度为n。si的构造方法如下:si=si−1t[i]si−1s_i=s_{i-1}t[i]s_{i-1}si=si−1t[i]si−1有1个询问,问你sks_ksk中有多少个w题解:首先这个构造方法就能看出来不能直接暴力地去做。那么我们找到第一个sis_isi使得∣si∣>∣w∣|s_i|>|w|∣si∣>∣w∣。可以发现,si在之后出现的次数每次都是*2.那么我们只需要找到si中有多少个w即可。那么对于i+1~n的情况该原创 2021-02-03 13:28:58 · 189 阅读 · 0 评论 -
15届黑龙江省赛 C. Cornelia Street —— 双哈希
This way题意:给你一个字符串s,让你求串A和B1.|A|=|B|2.s=AAA…AAABBB…BBBAAA…AAAa(n个A,m个B,k个A,|a|<|A|)n,m,k>0题解:A的长度和B相等,那么就很好做了,首先可以想到的是调和级数。那么枚举长度,检查接下来是否是ABA这种出现形式,f就表示当前是A还是B。如果到了结尾并且f=1的话,就说明最后k个A没有出现。使用了双哈希#include<bits/stdc++.h>using namespace s原创 2020-12-14 12:32:04 · 443 阅读 · 0 评论 -
POJ 2774 Long Long Message —— 后缀自动机求两个串的最长公共子串
This way题意:给你两个串,问你他们的最长公共子串的长度为多少题解:后缀自动机,大致细节我都写在注释里面了#include<iostream>#include<stdio.h>#include<cstring>using namespace std;#define ll long longconst int N = 2e5+1000;...原创 2019-07-25 09:06:49 · 336 阅读 · 0 评论 -
2019 Multi-University Training Contest 2 I Love Palindrome String —— hash+回文自动机
This way题意:给你一个字符串,让你输出n个数,分别是长度为i(1<=i<=n)的字符串有多少它本身是回文串且它前半部分(奇数包括最中间那位)是回文串。题解:回文自动机+哈希。回文自动机或者说回文树的话网上有很多博客,我觉得这一篇,还有2017年国家集训队翁文涛的论文,还有b站上回文树的视频看一看就基本上能够理解了。其中:len表示这个点为结尾的最长回文串的长度...原创 2019-07-31 21:33:15 · 217 阅读 · 0 评论 -
HDU 6629 string matching —— 扩展KMP
This way题意:有一个函数,它每次会暴力的去跑字符串s的所有后缀于字符串s的最长公共前缀,给你字符串s,问你这个函数会跑几次题解:学到了,模板。。这是逼我们baidu#include<bits/stdc++.h>#define ll long longusing namespace std;const int MAX=1000100; //字符串长度最大值in...原创 2019-08-13 20:54:56 · 252 阅读 · 0 评论 -
HDU 6661 Acesrc and String Theory —— 二分+hash 求一个字符串中有多少种连续出现k次的子串(不可区间重复)
This way题意:给你一个字符串,问你其中有多少连续出现k次的子串,计算时不可区间重复题解:有点难的题目,重要的是想到两个点:1.当已经有连续的大于等于k次子串的时候,后面的字符串与前面的最长公共前缀 也要算入答案,比如说ababac,k=2。ab出现了两次,ac与ab的最长公共前缀为a,那么答案就要再加1,因为ba也算。然后接下来的起始位置就是当前找到的最后的位置在减去当前位置...原创 2019-09-16 14:07:09 · 330 阅读 · 0 评论 -
The Preliminary Contest for ICPC Asia Shanghai 2019 G. Substring —— 特别的hash
This way题意:给你一个母串,q个询问,每次给你一个子串,设定两个串S,T相等当且仅当1.|S|=|T|2.S[0]=T[0]&&S[len-1]=T[len-1]3.S与T的组成集合相同。问你母串中有多少个子串题解:其它都想到了啊,但是怎么哈希没有想到,一般的哈希是h=h∗p+s[i]h=h*p+s[i]h=h∗p+s[i]这种形式,它可以判断先后,但是...原创 2019-09-16 19:01:14 · 291 阅读 · 0 评论 -
2019牛客国庆集训派对day1 C Distinct Substrings —— 二分+哈希
This way题意:给你一个串s,定义f(s)为这个字符串不同子串的数量,h©为f(s+c)-f(s)。问你题解:正解好像是扩展KMP,but二分+哈希也能过,就是要调一下哈希的值,23,29,31,101,131,这些我都过不去,最后自暴自弃试了一下1e9+7,它居然就过了,过了。。首先我们存下所有值出现的位置,由于这里没办法开1e6个vector,那么我们就模拟一个链表,ne[i...原创 2019-10-02 09:16:52 · 464 阅读 · 2 评论 -
HDU 4300 Clairewd’s message —— 字符串哈希
This way题意:现在给你26个字母对应的密文字符,现在有整个密文和不知道长度的明文组成的字符串,现在让你确定密文明文使得长度最小。题解:很明显是字符串哈希,并且这次我使用了双哈希。对于原来的字符串我们假设它全都是密文,先将它翻译成明文,将翻译前与翻译后的字符串进行双哈希,然后我们枚举密文的长度,如果枚举到的长度是可以的,什么是可以?就是剩下的长度x与密文的前面x长度的哈希值相等即可...原创 2019-07-18 19:10:45 · 223 阅读 · 0 评论 -
Codeforces Contest 958 problem A2 Death Stars (medium) —— 字符串hash求两个矩阵是否有相同部分
This way题意:给你一个nm的字符矩阵,一个mn的字符矩阵,问你他们相同的m*m的字符矩阵所在第一个矩阵的行数和第二个矩阵的列数。题解:我们把第一个字符矩阵当成一行处理,然后对于第二个字符矩阵,我们预处理所有的mm块将哈希值保存到左上角,如图:注意要用双哈希,但是脸黑也可能过不去。。之后我们就枚举第一个字符矩阵的起始位置,再枚举第二个字符矩阵的起始位置即可,时间复杂度nn,但是...原创 2019-05-26 19:32:17 · 322 阅读 · 0 评论 -
Codeforces Contest 1138 problem D Camp Schedule —— KMP求一个字符串的最长相同前后缀
The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp’s schedule. After some co...原创 2019-04-19 13:58:17 · 402 阅读 · 0 评论 -
最长回文 ——manacher
给出一个只由小写英文字符a,b,c…y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input 输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c…y,z组成的字符串S 两组case之间由空行隔开(该空行不用处理) 字符串长度len <= 110000 Output 每一行一个整数x,对应一组c...原创 2018-08-17 14:05:16 · 154 阅读 · 0 评论 -
HDU6230 Palindrome —— 马拉车+树状数组
Alice like strings, especially long strings. For each string, she has a special evaluation system to judge how elegant the string is. She defines that a string S1..3n−2 is one-and-half palindromic if ...原创 2018-08-17 18:29:44 · 437 阅读 · 0 评论 -
ACM-ICPC 2018 焦作赛区网络预赛 H. String and Times—— 后缀自动机
Now you have a string consists of uppercase letters, two integersAAA andBBB. We call a substring wonderful substring when the times it appears in that string is betweenAAA andBBB (A≤times≤BA ...原创 2018-09-19 13:11:45 · 415 阅读 · 0 评论 -
Problem J - Non Super Boring Substring —— 马拉车+树状数组(求不包含回文串区间的个数)
You’ll be given a string S and an integer K. You have to find the number of nonsuper-boring substring inside S. A substring is called super-boring if it contains anypalindromic substring of lengt...原创 2018-10-07 19:12:42 · 482 阅读 · 0 评论 -
Breaking the Curse Gym - 101840B 子串查找
Egypt has finally qualified to the World Cup 2018 after 28 years. It was almost a curse that has beenbroken. The main factor of this curse was the goal of Abdelghany in the World Cup 1990. Abdelghany...原创 2018-11-11 11:03:12 · 449 阅读 · 0 评论 -
Codeforces contest 1056 problem E Check Transcription —— 字符串hash
One of Arkady’s friends works at a huge radio telescope. A few decades ago the telescope has sent a signal s towards a faraway galaxy. Recently they’ve received a response t which they believe to be a...原创 2019-01-26 19:19:06 · 424 阅读 · 1 评论 -
Codeforces Contest 1120 problem C Compress String —— 字符串hash+dp 结构体unique的方法
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.To compress the string, you have to represent...原创 2019-03-22 15:57:47 · 404 阅读 · 0 评论 -
Codeforces Contest 1080 E Sonya and Matrix Beauty —— 马拉车求回文矩形个数
Sonya had a birthday recently. She was presented with the matrix of size n×m and consist of lowercase Latin letters. We assume that the rows are numbered by integers from 1 to n from bottom to top, an...原创 2019-03-29 16:31:22 · 335 阅读 · 0 评论 -
E - Slot Machines Gym - 101667I —— kmp
原文链接: https://odzkskevi.qnssl.com/6fd8c99567698f4bad5a228cc982bad7?v=1534480987这么长的题目我都看不懂,还是别人和我讲的题意,就是给你一串数字,前面可能是没有规律的,后面是有规律的,让你找出需要删掉k个数,然后循环内数的个数是p,k+p最小。 网上kmp算法很多,这个我是看别人的,它可以找到上一个循环的节点。...原创 2018-08-17 21:22:55 · 513 阅读 · 0 评论