题目:求一个字符串中所有不同子串个数
后缀数组经典题,每一个子串一定是某个后缀的前缀,那么问题便等价于求所有后缀之间的不相同的前缀个数。我们按sa的顺序来考虑,当加入sa[k]的时候,sa[k]这个后缀的长度为n-sa[k]-1,那么便有n-sa[k]-1个前缀,但是由heigh数组可知sa[k]与sa[k-1]有height[k]个前缀是相同的,所以要除去。
注意的是这道题题意有点坑,一开始...
分类:
编程语言 时间:
2015-07-16 22:27:50
阅读次数:
136
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation...
分类:
其他好文 时间:
2015-07-16 00:36:56
阅读次数:
151
http://acm.hdu.edu.cn/showproblem.php?pid=4455
Substrings
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2229 Accepted Submission(s...
分类:
其他好文 时间:
2015-07-04 16:47:53
阅读次数:
121
【题目链接】click here~~
【题目大意】:
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings “AB” and “BA” (the substrings can go in any order).
Inp...
分类:
其他好文 时间:
2015-06-27 16:44:19
阅读次数:
145
SubstringsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8183Accepted Submission(s): 3752Problem ...
分类:
其他好文 时间:
2015-06-23 15:01:42
阅读次数:
142
题目链接 题目要求: Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possib...
分类:
其他好文 时间:
2015-06-16 16:08:21
阅读次数:
120
A. Two Substrings
题意:问一个字符串中是否同时存在AB和BA,其中AB和BA不能共用同一个B或A。
题解:扫一遍即可。可以考虑如下策略:先找AB,然后从B后的位置继续找BA;再另按BA-AB的顺序找一遍即可。复杂度O(n)O(n)。窝的代码则直接暴力出所有的AB和BA位置,只要出现不重叠的两个就OKOK~数据不大,随便搞。
参考代码:
#include <bits/stdc++.h...
分类:
其他好文 时间:
2015-06-11 09:34:23
阅读次数:
263
【题目链接】click here~~
【题目大意】:
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings “AB” and “BA” (the substrings can go in any order).
Input...
分类:
其他好文 时间:
2015-06-09 17:24:38
阅读次数:
105
You are given string s. Your task is to determine if the given string s contains
two non-overlapping substrings "AB" and "BA" (the substrings
can go in any order).
Input
The only line of...
分类:
其他好文 时间:
2015-06-09 17:21:51
阅读次数:
184
题目:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representat...
分类:
其他好文 时间:
2015-06-09 06:13:42
阅读次数:
93