摘要:问题:求一个字符串的最长回文子串。 解决方案:利用后缀数组,设这个字符串是S,S'是这个字符串的反转,设T=S+'$'+S',则所有的回文子串一定会出现在字符串T当中的其中两个后缀的前缀上,所以只要求T的lcp,利用lcp求后缀之间的相同前缀的最大长度。 代码参考:
阅读全文
摘要:Stand in a Line Uva 11174 题意:把n个人排成一列,使得没有人排在他父亲的前面,输出方案数MOD 1000000007 思路:《算法竞赛入门经典》P 111 AC代码:
阅读全文
摘要:UVA 11375 Matches 题意:用火柴棍搭数字,能搭多少个非负整数(不能有前导0,数字0是可以的,6根火柴即可搭出)。设一共有n根火柴。 思路:dp+大整数 设dp[i]:用i根火柴正好能搭的数字的个数 设搭出每个数字j(0<=j<=9)需要的火柴数为c[j]. 那么动态转移方程:dp[i
阅读全文
摘要:Facer’s string Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 2155 Accepted: 644 Description Minifacer was very happy these days because h
阅读全文
摘要:Boatherds Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3588 Accepted: 1159 Description Boatherds Inc. is a sailing company operating in
阅读全文
摘要:Common Substrings Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 12585 Accepted: 4228 Description A substring of a string T is defined as:
阅读全文
摘要:Glass Beads Time Limit: 3000MS Memory Limit: 10000K Total Submissions: 4868 Accepted: 2749 Description Once upon a time there was a famous actress. As
阅读全文
摘要:The Fewest Coins Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7311 Accepted: 2255 Description Farmer John has gone to town to buy some f
阅读全文
摘要:Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 67208 Accepted: 19082 Case Time Limit: 5000MS Description An array of size
阅读全文
摘要:Batch Scheduling Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4395 Accepted: 2013 Description There is a sequence of N jobs to be proces
阅读全文
摘要:Largest Submatrix of All 1’s Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 7700 Accepted: 2779 Case Time Limit: 2000MS Description Given
阅读全文
摘要:Bad Hair Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 21084 Accepted: 7202 Description Some of Farmer John's N cows (1 ≤ N ≤ 80,000)
阅读全文
摘要:《挑战程序设计竞赛》P345 观看计划 题意:一周一共有M个单位的时间。一共有N部动画在每周si时开始播放,ti时刻播放结束,问每周最多能看多少部动画。 思路:贪心+倍增法 可以看成一个圆周上有N个区间,找出N个区间中尽可能多的互不相交的区间。选定一个区间作为起始区间后,贪心思想是:每次尽量选取与当
阅读全文
摘要:Dollar Dayz Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8672 Accepted: 3233 Description Farmer John goes to Dollar Days at The Cow Stor
阅读全文
摘要:Space Elevator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12817 Accepted: 6092 Description The cows are going to space! They plan to a
阅读全文