——字符串处理——
LP_Cong
Python, Qt C++ Developer ACMer https://github.com/Linzecong
展开
-
HDU - 6144 Arithmetic of Bomb
Arithmetic of BombProblem Description众所周知,度度熊非常喜欢数字。它最近在学习小学算术,第一次发现这个世界上居然存在两位数,三位数……甚至N位数!但是这回的算术题可并不简单,由于含有表示bomb的#号,度度熊称之为 Arithmetic of Bomb。![](../../../data/images/C777-原创 2017-08-18 16:58:29 · 586 阅读 · 0 评论 -
计蒜客 Skr (2018 ICPC亚洲区域赛网络赛 南京 I)(回文树)
题目链接:https://nanti.jisuanke.com/t/30998A number is skr, if and only if it's unchanged after being reversed. For example, "12321", "11" and "1" are skr numbers, but "123", "221" are not. FYW has a st...原创 2018-09-01 21:00:56 · 480 阅读 · 0 评论 -
HDU - 6299 Balanced Sequence (2018 Multi-University Training Contest 1 B)
Balanced SequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2043 Accepted Submission(s): 504 Problem DescriptionChiaki has n str...原创 2018-07-24 13:51:00 · 278 阅读 · 0 评论 -
HDU - 4757 Tree (可持久化字典树)
TreeTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 2811 Accepted Submission(s): 812Problem Description Zero and One are good friends who...原创 2018-05-08 14:32:51 · 316 阅读 · 0 评论 -
HDU - 4825 Xor Sum(01字典树)
Xor SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 4040 Accepted Submission(s): 1760Problem DescriptionZeus 和 Prometheus 做了一个游戏,Prometh...原创 2018-05-07 19:25:31 · 187 阅读 · 0 评论 -
HDU - 5421 Victor and String (双向插入回文树)
Victor and StringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/262144 K (Java/Others)Total Submission(s): 680 Accepted Submission(s): 214Problem DescriptionVictor loves to play wit...原创 2018-04-25 18:13:46 · 298 阅读 · 0 评论 -
HYSBZ - 2160 拉拉队排练 (回文树)
2160: 拉拉队排练Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 2216 Solved: 858[Submit][Status][Discuss]Description艾利斯顿商学院篮球队要参加一年一度的市篮球比赛了。拉拉队是篮球比赛的一个看点,好的拉拉队往往能帮助球队增加士气,赢得最终的比赛。所以作为拉拉队队长的楚雨荨同学知道,帮助篮球队训...原创 2018-04-25 17:01:35 · 212 阅读 · 0 评论 -
HDU - 5658 CA Loves Palindromic (回文树模板)
CA Loves PalindromicTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 622 Accepted Submission(s): 252Problem DescriptionCA loves strings, esp...原创 2018-04-25 15:44:20 · 251 阅读 · 0 评论 -
CodeForces - 931E Game with String (思维)
Game with Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya and Kolya play a game with a string, using the following rules. Initially, K...原创 2018-03-27 18:29:11 · 676 阅读 · 0 评论 -
HDU - 6191 Query on A Tree (可持久化字典树 | 字典树合并)
Query on A TreeTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 1692 Accepted Submission(s): 558 Problem DescriptionMonkey A lives...原创 2018-09-02 16:23:16 · 376 阅读 · 0 评论 -
计蒜客 Set (2018 ICPC亚洲区域赛网络赛 南京 H)(字典树合并)
Shinku is very interested in the set. One day, she got nn sets, and the ii-th number a_iai is in the ii-th set. But she doesn't think it is interesting enough, so she applies mm magic to these sets. ...原创 2018-09-02 22:00:25 · 678 阅读 · 0 评论 -
hihoCoder - 1871 Heshen's Account Book (2018ICPC北京B)
时间限制:1000ms单点时限:1000ms内存限制:512MB描述Heshen was an official of the Qing dynasty. He made a fortune which could be comparable to a whole country's wealth by corruption. So he was known as the most...原创 2018-11-12 19:40:10 · 498 阅读 · 0 评论 -
SPOJ - LCS Longest Common Substring (后缀自动机)
求两个串的最长公共子串保存我的模板! #include<bits/stdc++.h>using namespace std;const int MAXN=500005;typedef long long ll;int step[MAXN];int SZ=1;int ch[MAXN][30];int fa[MAXN];int last=1;void e...原创 2018-10-17 15:07:05 · 241 阅读 · 0 评论 -
Gym - 101908H Police Hypothesis (字符串哈希 + 树链剖分 + 区间合并)
H. Police Hypothesistime limit per test8.0 smemory limit per test1024 MBinputstandard inputoutputstandard outputThe public transport system of Nlogônia has an express network connect...原创 2018-10-19 16:30:18 · 342 阅读 · 0 评论 -
牛客国庆集训派对Day5 H-我不爱她 (KMP+字符串哈希)
链接:https://www.nowcoder.com/acm/contest/205/H来源:牛客网 题目描述终于活成了自己讨厌的样子。 天空仍灿烂,它爱着大海。 你喜欢大海,我爱过你。 世界上充满了巧合。我们把每句话当成一个字符串,我们定义a对b的巧合值为a的最长后缀的长度并且它是恰好是b的前缀,这里的后缀或者前缀包括字符串的本身。比如字符串“天空仍灿烂她喜...原创 2018-10-07 16:37:44 · 401 阅读 · 0 评论 -
Gym - 101889M Marblecoin (后缀数组妙用)
题意:给你N个栈,每天从任意一个栈中取出一个数,数在手上每保留一天,价值*365。所有数字拿完后,求手上的数子的最小价值。 解题思路:看到题目,初始数字不大于365,所以很容易想到贪心,每次必然是取这N个栈中,栈顶最小的那个数。然后就会想到用优先队列维护每个栈的栈顶。但是这样有一个问题,栈顶相同怎么办?那就看第二个数谁大,还一样就看第三个数。所以就要想着怎么给这N个栈动态的排...原创 2018-10-13 21:31:39 · 466 阅读 · 0 评论 -
CodeForces - 985F Isomorphic Strings(字符串Hash哈希)
F. Isomorphic Stringstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of length n consisting of lowercas...原创 2018-10-07 14:03:54 · 456 阅读 · 0 评论 -
牛客国庆集训派对Day1 D-Love Live! (启发式合并+01字典树)
链接:https://www.nowcoder.com/acm/contest/201/D来源:牛客网 题目描述因为招生办的招生政策变化,Otonokizaka Academy的ACM-ICPC team面临废队危机。Honoka Kosaka,Kotori Minami,Umi Sonoda等人决定成为偶像来吸引更多的学生参加ICPC。Honoka决定选取一些动作来编舞。我们把所有...原创 2018-10-03 15:45:19 · 530 阅读 · 2 评论 -
牛客国庆集训派对Day1 J-Princess Principal (区间查询是否是正确的括号匹配)
链接:https://www.nowcoder.com/acm/contest/201/J来源:牛客网 阿尔比恩王国(the Albion Kingdom)潜伏着一群代号“白鸽队(Team White Pigeon)”的间谍。在没有任务的时候,她们会进行各种各样的训练,比如快速判断一个文档有没有语法错误,这有助于她们鉴别写文档的人受教育程度。这次用于训练的是一个含有n个括号的文档。括号一...原创 2018-10-03 13:34:47 · 499 阅读 · 0 评论 -
HDU - 5008 Boring String Problem (后缀数组+二分+RMQ)
Boring String ProblemTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2160 Accepted Submission(s): 588Problem DescriptionIn th原创 2018-02-03 20:05:03 · 328 阅读 · 0 评论 -
POJ - 2774 Long Long Message (最长公共子串 后缀数组)
Long Long MessageTime Limit: 4000MS Memory Limit: 131072KTotal Submissions: 32777 Accepted: 13206Case Time Limit: 1000MSDescriptionThe little cat is maj原创 2018-01-25 13:08:41 · 330 阅读 · 0 评论 -
ZOJ - 3985 String of CCPC (2017CCPC秦皇岛站 简单题)
String of CCPCTime Limit: 1 Second Memory Limit: 65536 KBBaoBao has just found a string of length consisting of 'C' and 'P' in his pocket. As a big fan of the China Collegiate Pro原创 2017-11-07 17:56:38 · 529 阅读 · 0 评论 -
HDU - 1251 统计难题 (字典树模板)
统计难题Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,原创 2017-11-08 16:59:07 · 247 阅读 · 0 评论 -
HDU - 3746 Cyclic Nacklace (KMP模板)
Cyclic NacklaceProblem DescriptionCC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he原创 2017-11-14 16:37:39 · 236 阅读 · 0 评论 -
HDU - 6208 The Dominator of Strings (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1003)
The Dominator of StringsProblem DescriptionHere you have a set of strings. A dominator is a string of the set dominating all strings else. The string S is dominated by T if S is a subs原创 2017-09-17 20:01:34 · 1436 阅读 · 0 评论 -
HDU - 6170 Two strings
Two stringsProblem DescriptionGiving two strings and you should judge if they are matched.The first string contains lowercase letters and uppercase letters.The second string contains low原创 2017-08-22 21:06:20 · 554 阅读 · 5 评论 -
POJ - 3280 Cheapest Palindrome(区间DP)
解题报告:是时候深入学习下DP了,字符串题,枚举每一个字符,从每一个字符开始,往左枚举区间,区间从小到大,这个时候就有递推公式,当s[i]==s[j]时,就已经是回文串了,这个时候的最小值肯定就是两边都相减1,即dp[i+1][j-1]。如果不相等,那么要么往左边添加或删除,要么往右边添加或删除,在这里,添加和删除操作是等价的,因此直接去最小值。原创 2017-08-08 19:59:49 · 215 阅读 · 0 评论 -
POJ - 2955 Brackets (区间DP)
区间DP问题,首先枚举区间,根据题目第二个条件,如果符合则匹配数+2,根据题目第三个条件还要进行中间分隔,枚举所有情况。dp[i][j]代表i到j这个区间的最大匹配数,那么如果s[i]==s[j],dp[i][j]=dp[i+1][j-1]+2,然后我们再枚举中间截断的情况,dp[i][j]=max(dp[i][j],dp[i][k]+dp[k+1][j]),详见代码。原创 2017-08-08 21:14:52 · 229 阅读 · 0 评论 -
POJ - 1141 Brackets Sequence (区间DP)
解题思路:参考最小括号匹配那题http://blog.csdn.net/lzc504603913/article/details/76944119那题输出最小匹配数,这题刚好相反,你要补最少的括号,使其可以完全匹配,思路类似,dp[i][j]存i到j这个区间内需要补的最少括号,如果s[i]==s[j],那么不用补,然后从中间枚举,并记录截断的位置,用于输出。详见代码注释。原创 2017-08-08 22:10:25 · 293 阅读 · 2 评论 -
HDU - 4117 GRE Words (AC自动机+Fail树+线段树+DFS序+DP)
GRE WordsProblem DescriptionRecently George is preparing for the Graduate Record Examinations (GRE for short). Obviously the most important thing is reciting the words.Now George is workin原创 2017-11-20 21:21:41 · 3254 阅读 · 2 评论 -
HDU - 2609 How many (字符串的最小表示)
How manyProblem DescriptionGive you n ( n How many kinds of necklaces total have.(if two necklaces can equal by rotating ,we say the two necklaces are some).For example 0110 express a原创 2017-11-15 22:46:32 · 350 阅读 · 0 评论 -
SPOJ - REPEATS (后缀数组+RMQ)
REPEATS - Repeatsno tags A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the strings = abaabaabaab...原创 2018-01-24 20:06:26 · 305 阅读 · 0 评论 -
POJ - 2406 Power Strings(next数组妙用+后缀数组)
Power StringsDescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as mult原创 2017-11-14 17:42:46 · 356 阅读 · 0 评论 -
POJ - 3261 Milk Patterns (后缀数组+二分)
Milk PatternsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 16776 Accepted: 7409Case Time Limit: 2000MSDescriptionFarmer John has noticed that th原创 2017-12-03 21:19:55 · 251 阅读 · 0 评论 -
POJ - 1743 Musical Theme (后缀数组模板)
Musical ThemeDescriptionA musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate原创 2017-12-03 20:38:30 · 288 阅读 · 0 评论 -
HDU - 2457 DNA repair(AC自动机+DP)
DNA repairProblem DescriptionBiologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA is represen原创 2017-11-23 16:30:48 · 384 阅读 · 0 评论 -
SPOJ - 7758 (MGLAR10 - Growing Strings)(AC自动机+DP 数组实现)
Gene and Gina have a particular kind of farm. Instead of growing animals and vegetables, as it is usually the case in regular farms, they grow strings. A string is a sequence of characters. Strings ha原创 2017-11-20 16:12:42 · 337 阅读 · 0 评论 -
GYM - 100812K Might and Magic (构造字符串)
Might and Magictime limit per test4.0 smemory limit per test256 MBinputstandard inputoutputstandard outputI was walking upstairs directly to the tower of Dragon原创 2017-12-03 00:21:28 · 279 阅读 · 0 评论 -
HDU - 2222 Keywords Search(AC自动机模板 指针实现)
Keywords SearchProblem DescriptionIn the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval原创 2017-11-16 14:30:10 · 346 阅读 · 0 评论 -
Gym - 100548I International Collegiate Routing Contest (01字典树)
题意:给你多个子网掩码,要你求一个最小的子网掩码补集。 解题思路:IPV4一共有 2^32个地址,实际上对应的就是一个完全字典树。现在给定的子网掩码,实际上就是给定了一个字典树,然后要你求这个字典树的补树,使得是一个完全字典树。实际上就是求这个字典树的所有补树形成的森林。那么我们只要深搜即可。然后记录下答案,然后还原下答案即可。 #include <bits/...原创 2018-11-16 21:51:09 · 327 阅读 · 0 评论