算法设计
文章平均质量分 81
ACM-算法之道
潜心潜力,深入分析每一个问题,每一个算法
展开
-
hihocoder #1084 (后缀数组求模糊匹配)
#1084 : 扩展KMP时间限制:4000ms单点时限:4000ms内存限制:256MB描述你知道KMP吗?它是用于判断一个字符串是否是另一个字符串的子串的算法。今天我们想去扩展它。在信息理论中,在两个相同长度的字符串之间的海明码距离是:两个字符串相同位置对应的字符不同的位置数目。换种说法,它表示将一个字符串转化为另一个字符串所需要原创 2014-12-14 23:27:25 · 776 阅读 · 0 评论 -
Topcoder SRM 635 Div2 1000 (一种 O(n) 求一棵树中最长连续边 长度的方法)
//Hello. I'm Peter.#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo原创 2014-10-05 04:23:22 · 1030 阅读 · 0 评论 -
UVALive 3263(欧拉公式,V-E+F==2,几何模版 is under-construction...)
B - That Nice Euler CircuitTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 3263Appoint description: System Crawler (2014-10-08)原创 2014-10-15 09:52:16 · 995 阅读 · 0 评论 -
HDU 4436 str2int(后缀数组,一种统计n个digit字符串所有不同子串之和的方法)
str2intTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1448 Accepted Submission(s): 500Problem DescriptionIn this problem,原创 2014-11-17 19:06:28 · 743 阅读 · 0 评论 -
Topcoder SRM 636 Div2 1000(切蛋糕,最后一块给自己。最小值中求最大值,二分+枚举)
Problem Statement Mirosz adores sweets. He has just bought a rectangular bar of chocolate. The bar is divided into a grid of square cells. Different cells may have a different quality. Yo原创 2014-10-15 04:50:14 · 871 阅读 · 0 评论 -
Arab Collegiate Programming Contest 2012G. Archery(求雷达扫描的期望,区间离散化)
G. Archerytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLast summer you were watching all the matches in原创 2014-11-15 16:06:15 · 986 阅读 · 0 评论 -
UVA11019 Matrix Matcher(一种计算子矩阵在母矩阵中出现次数的办法,AC自动机+kmp)
Problem HMatrix MatcherInput: Standard InputOutput: Standard Output Given an N * M matrix, your task is to find the number of occurences of an X * Y pattern. InputThe first line contai原创 2014-10-12 00:32:33 · 487 阅读 · 0 评论 -
Codeforces gym 2013-2014 Samara SAU ACM ICPC Quarterfinal Qualification Contest
今天遇到了件怪事原创 2014-10-27 02:29:55 · 2368 阅读 · 0 评论 -
Topcoder SRM 152 Div2 1000(状态压缩呀)
Problem Statement A large company is trying to put together a team of people to work on some task. In order for any team to work well, the people involved must be able to get along with eac原创 2014-10-19 00:48:11 · 474 阅读 · 0 评论 -
Codeforces 128B. String(优先队列,模仿dijkstra求最短路)
B. Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day in the IT lesson Anna and Maria learned a原创 2014-11-04 21:21:27 · 797 阅读 · 0 评论 -
Topcoder SRM 640 Div2 1000(巧妙数学题)
Problem Statement A multiset is the same thing as a set, with the difference that a multiset can contain multiple copies of the same element. For example, {1,1,1,2,3} is a multiset that c原创 2014-12-12 14:50:29 · 798 阅读 · 0 评论 -
Topcoder SRM 641 Div1 250(另辟蹊径,排除法)
Problem Statement We have chosen a finite set of points in the plane. You are given their coordinates in the vector sx and y: for each valid i, there is a point with coordinates (x[i],y[i原创 2014-12-12 14:14:46 · 716 阅读 · 0 评论 -
UVALive 5908 Tracking RFIDs(计算几何+数据结构,暴力也可过)
A - Tracking RFIDsTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 5908Appoint description: System Crawler (2014-12-04)Descri原创 2014-12-04 13:59:02 · 805 阅读 · 0 评论 -
Codeforces 484B. Maximum Value(高效二分搜索)
B. Maximum Valuetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence a consisting of n原创 2014-11-30 12:52:51 · 1352 阅读 · 0 评论 -
Codeforces 383C. Propagating tree(树上hash映射+线段树懒操作)->(一种将树结点规律化的方法)
C. Propagating treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub likes trees very much. Recently h原创 2014-11-06 21:15:52 · 902 阅读 · 1 评论 -
Codeforces 487B. Strip(求区间最值+线段树上的dp)
题目:Codeforces 487B. Strip(#278Div.1 B题)描述:将一个长度为n的数列划分成m个部分,要求每个部分含有的个数>=L,且每个部分最大值-最小值<=S,求满足上述两个条件情况下m的最小值。即划分区间个数最小方法:线段树求区间最值,在线段树上进行动态规划,线段树懒操作复杂度:O(nlogn),n为数列元素个数此题所需方法巧妙,很有助于算法提高,有助于提高线段树基本写法原创 2014-11-23 02:50:00 · 1590 阅读 · 0 评论 -
UVA 11997 Smallest Sums(有序表合并,多维变一维)
AA - K Smallest SumsTime Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVA 11997Appoint description: System Crawler (2014-11-25)Des原创 2014-11-27 15:42:01 · 414 阅读 · 0 评论 -
UVA 12304(计算几何大综合题)
//Hello. I'm Peter.#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo原创 2014-10-20 20:30:35 · 1098 阅读 · 0 评论 -
Codeforces 490D. Chocolate(分解质因数求解)
D. Chocolatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus likes giving presents to Paraskevi.原创 2014-11-26 17:17:38 · 813 阅读 · 0 评论 -
Codeforces gym 2011-2012, Samara Interacademic Programming
Codeforces gym 2011-2012, Samara Interacademic Programming原创 2014-11-12 21:57:45 · 1450 阅读 · 0 评论 -
Codeforces gym 2014 Nordic Collegiate Programming Contest(最初版,有过题再更新)
//Hello. I'm Peter.#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo原创 2014-10-25 20:13:50 · 651 阅读 · 0 评论 -
Codeforces 472B. Design Tutorial: Learn from Life(坐电梯扯淡题)
//Hello. I'm Peter.#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo原创 2014-09-29 03:27:14 · 713 阅读 · 0 评论 -
Codeforces 467D. Fedor and Essay (Graphs,dfs,dp,hashing,strings,图论综合型好题)
D. Fedor and Essaytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter you had helped Fedor to find frien原创 2014-09-21 04:21:41 · 666 阅读 · 0 评论 -
Topcoder SRM 144 Div2 1100 (树形dp)
Problem Statement You work for an electric company, and the power goes out in a rather large apartment complex with a lot of irate tenants. You isolate the problem to a network of sewers原创 2014-09-08 23:27:27 · 508 阅读 · 0 评论 -
Codeforces 263 C. Circle of Numbers D. Cycle in Graph (dfs一般难度)
//Hello. I'm Peter.#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo原创 2014-09-09 22:07:18 · 770 阅读 · 0 评论 -
Codeforces 464A. No to Palindromes! (dp,向前推理,向后查询)
//Hello. I'm Peter.#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo原创 2014-09-08 23:31:55 · 564 阅读 · 0 评论 -
Codeforces 464B. Restore Cube (一种高效八点判断立方体(cube)的办法)
B. Restore Cubetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeter had a cube with non-zero length of a s原创 2014-09-08 23:36:55 · 1028 阅读 · 0 评论 -
Codeforces 463D. Gargari and Permutations (dp,distinct下的LCS问题)
D. Gargari and Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGargari got bored to play with原创 2014-09-08 23:37:16 · 603 阅读 · 0 评论 -
Codeforces 458A (01串下黄金分割公式的拓展公式)
http://codeforces.com/contest/458/problem/A 题目地址题目大意:给两个01字符串,即字符串只含有0或1,原创 2014-08-11 22:57:19 · 786 阅读 · 0 评论 -
Codeforces 432C (哥德巴赫猜想的巧妙应用)
C. Prime Swapstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a[1], a[2], ..., a[n], con原创 2014-08-17 23:37:35 · 1274 阅读 · 0 评论 -
Codeforces 417E Square Table(随机算法)
转载自:http://blog.csdn.net/keshuai19940722/article/details/24105103今天学了个新姿势,随机算法。bu转载 2014-08-05 22:10:44 · 500 阅读 · 0 评论 -
UVALive 3026 Period (KMP上的dp,学习ac自动机的前奏)
A BB - PeriodTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 3026Appoint description: System Crawler (2014-09-22)Descr原创 2014-09-22 01:35:03 · 545 阅读 · 0 评论 -
HDU 3336 (KMP上的dp问题,ac自动机我来了)
Count the stringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4845 Accepted Submission(s): 2295Problem DescriptionIt is wel原创 2014-09-15 04:08:12 · 674 阅读 · 0 评论 -
SGU 411Petya the Hero(最长公共回文子串,AC自动机+n^2判断回文)(学习后缀数组的前奏)
411. Petya the HeroTime limit per test: 0.25 second(s)Memory limit: 65536 kilobytesinput: standardoutput: standardPetya has come back from the Berland-Birland War, and now he is fond原创 2014-11-11 21:39:53 · 581 阅读 · 0 评论 -
Codeforces 472D. Design Tutorial: Inverse the Problem(一种逆向判定树成立的办法,从Kruskal到dfs)
D. Design Tutorial: Inverse the Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an easy wa原创 2014-09-29 14:11:12 · 804 阅读 · 0 评论 -
Topcoder SRM 148 Div2 1000(dfs搜索+hash判重)
Problem Statement 9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. Fo原创 2014-10-07 21:59:07 · 482 阅读 · 0 评论 -
POJ 3461 Oulipo (KMP,求模版串在文本串中可覆盖出现的次数,constructive)
OulipoTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 24213 Accepted: 9711DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La原创 2014-09-17 02:31:28 · 959 阅读 · 0 评论 -
CDOJ 251 导弹拦截 (LIS,一种找到字典序最小的最长上升子序列的方法)
导弹拦截Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)Submit Status某国为了防御敌国的导弹袭击,开发出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都要高于前一发的原创 2014-09-17 01:21:37 · 2046 阅读 · 1 评论 -
Nim游戏,异或解决问题,神证明
http://baike.baidu.com/view/1101962.htm?fr=aladdin#4Nim游戏编辑本词条缺少信息栏、名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧!Nim游戏是博弈论中最经典的模型(之一),它又有着十分简单的规则和无比优美的结论 Nim游戏是组合游戏(Combinatorial Games)的一种,准转载 2014-09-14 19:32:21 · 2355 阅读 · 0 评论 -
CDOJ 843 冰雪奇缘 (线段树+懒操作+离散化)
冰雪奇缘Time Limit: 30000/10000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)Submit Status艾莎女王又开始用冰雪魔法盖宫殿了。她决定先造一堵墙,于是释放魔法让形为直角梯形的冰砖从天而降,定入冻土之中。现在你将回答女王的询问:某段冻土上冰原创 2014-09-13 17:58:46 · 959 阅读 · 0 评论