http://www.spoj.com/problems/SUBLEX/后缀自动机系列完成QAQ。。。撒花。。明天or今晚写个小结?首先得知道:后缀自动机中,root出发到任意一个状态的路径对应一个子串,而且不重复。(原因似乎是逆序后缀树?所以我们在自动机上预处理每一个状态的子串数目,然后从小到大枚...
分类:
其他好文 时间:
2014-12-05 14:12:33
阅读次数:
253
http://www.spoj.com/problems/LCS2/发现了我原来对sam的理解的一个坑233本题容易看出就是将所有匹配长度记录在状态上然后取min后再对所有状态取max。但是不要忘记了一点:更新parent树的祖先。为什么呢?首先如果子树被匹配过了,那么长度一定大于任意祖先匹配的长度...
分类:
其他好文 时间:
2014-12-05 07:04:26
阅读次数:
318
Longest Substring Without Repeating Characters...
分类:
其他好文 时间:
2014-12-04 21:39:24
阅读次数:
237
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2014-12-04 21:12:36
阅读次数:
269
http://www.lydsy.com/JudgeOnline/problem.php?id=2555学到了如何快速维护right值orz(虽然这仍然是暴力维护,但是这是O(n)的暴力233首先我们在加一个新节点的时候直接遍历它的parent树就行啦啦!!!!这样直接就暴力维护了。。。我竟然没想到...
分类:
其他好文 时间:
2014-12-04 19:45:54
阅读次数:
154
比较字符串:str1.CompareTo("abc");定位运算符:str1.IndexOf("abc");格式化运算符:?截取字符串:str.Substring(0,5);分裂字符串:str.Split('.','!');插入字符串:str.Insert(10,"beautiful");填充字符串...
分类:
其他好文 时间:
2014-12-04 13:43:30
阅读次数:
146
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2014-12-03 23:15:35
阅读次数:
248
截取字符串range我们可以通过 Range 截取字符串的字串:import Foundation
var str = "Aha, hello, why"
let rangeOfHello = Range(start: advance(str.startIndex, 5), end: advance(str.startIndex, 10))
let helloStr = str.substring...
分类:
编程语言 时间:
2014-12-03 21:18:37
阅读次数:
471
1.将String转化为NSString再截取,代码如下: var s="1234567890"var ns1=(s as NSString).substringFromIndex(5)var ns2=(s as NSString).substringToIndex(4)var ns3=(s as ...
分类:
编程语言 时间:
2014-12-03 18:56:09
阅读次数:
224
定义变量:#set($str = “CNF”) 调用方法:$str.SubString(0,1) 输出:C 定义变量:#set($a = 123) 调用方法:$a.GetType()输出:System.Int32减法:(减法要用如下形式,否则如果用 #set($aa= $bb-1) 再在...
分类:
其他好文 时间:
2014-12-03 18:36:55
阅读次数:
565