自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(100)
  • 资源 (1)
  • 收藏
  • 关注

Splay解决区间问题[区间切割,区间翻转]

区间翻转:由于以root为根的树的中序遍历表示该区间,那么翻转只要递归的交换左右子树即可,加入lazy思想,降低时间复杂度。Tips:做区间翻转的时候rev[rt]的含义是——以rt为根的子树所表示的区间是否将要被翻转,目前并没有执行翻转操作,如果改成先翻转,再标记,就会出现大问题。Code:没用的push_down写多了。/*http://acm.hdu.edu.cn/showpr...

2013-02-02 23:44:00 344

Splay解决区间问题[区间更新,区间求和]

/*http://poj.org/problem?id=3468*//*区间更新,区间求和*//*注意各种编码细节,特别是splay buildTree和 rotateTo*//*仔细体会与线段树解决区间问题的不同点,如结点记录的信息是不同的*//*lazy思想*/#include<iostream>#include<cstdio>#include<cs...

2013-01-31 22:50:00 437

Splay解决区间问题[单点更新,区间最值询问]

/*http://acm.hdu.edu.cn/showproblem.php?pid=1754*//*单点更新,区间询问 splay实现*//*注意写rotateTo的时候。。*/#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using na...

2013-01-31 21:20:00 182

SplayTree实现_简化版

(1)template<class DataType>class SplayTree{#define MAXN 1000010private: int ch[MAXN][2],pre[MAXN],pool[MAXN]; DataType key[MAXN]; int top,root,tot; int malloc(DataType dt){...

2013-01-31 18:54:00 176

SplayTree实现

template<class DataType>class SplayTree{#define null 0private: int MAXSIZE; int *l,*r,*p,*pool,*depth; int top,root,tot; DataType *key; int malloc(DataType k){ int...

2013-01-30 23:41:00 155

Codeforces #163 Div2 E

传送门:http://codeforces.com/contest/266/problem/E代码:#include<iostream>#include<cstdio>#include<cmath>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,...

2013-01-27 15:09:00 164

关于sigma(被我写成了segma)

本博客之前所有的求和符号都写成了segma。。。。。。。。。。英语巨烂的弱菜表示错的深刻。。所以如果有人看到segma什么的,就自动转型成sigma吧。。。求和==sigma...

2012-06-28 00:48:00 307

[KMP-next数组特性]HDU 2594 Simpsons’ Hidden Talents

如果不了解next数组前缀后缀特性的请看我以前写的一道题:http://blog.csdn.net/airarts_/article/details/7686441传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2594题目大意:给定字符串s1,s2要求出s1的最长前缀,同时还是s2的最长后缀,输出该字符串和其长度.解题思路:利用前缀后缀...

2012-06-27 17:37:00 167

[KMP-循环节问题]HDU 1358 period

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1358题目大意:给定一个字符串,求出所有循环的前缀串,输出前缀串的长度和循环的次数(大于一才算循环串)思路:同上一道题一样,也是求循环节,这里,枚举长度为2-N的所有前缀串(next数组可以一次预处理求出),求出其最小循环节,判断前缀串长度是否可以整除循环节长度整除,并且前缀串长度不等于循环节长度...

2012-06-27 17:13:00 174

[KMP-求循环节]HDU 3746 Cyclic Nacklace

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3746题目大意:给定一个字符串,求出最少在末尾添加几个字符使得字符串成为循环串。解题思路:先求出最小循环节,如果最小循环节长度等于字符串长度,则添加的字符数为字符串的长度,否则用字符串的长度模循环节的长度,如果为0,说明已经是循环串,如果非0,说明还要添加字符串长度减去该值个字符.代码:...

2012-06-27 16:53:00 153

[KMP-NEXT数组特性]HDU 3336 Count the string

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3336题目大意:给定一个字符串(1-200000),求出其所有前缀在自身中匹配成功的次数之和(模10007)解题思路:利用next数组的特性,next[pos]在主串指针在pos位置失配时,子串指针应该调整到next[pos]与pos进行比较,这意味着0-(next[pos]-1)的字符串应该和(...

2012-06-27 11:39:00 146

[割点问题]HOJ 12307 Disconnected Pair

传送门:http://acm.hnu.cn/online/?action=problem&type=show&id=12307题目大意:给定一个联通图,求出能有多少种不同的方式去除两个不同的点使得原图变的不联通。关于解题:这道是上次校赛的一道题,比赛当时没仔细想,也没仔细看数据,压根就没想枚举割点,后来听解题报告的时候恍然大悟,这道题可以先用tarjan求一次割点,然后对于...

2012-06-24 18:43:00 125

[KMP或者暴力]POJ 3450 Corporate Identity

传送门:http://poj.org/problem?id=3450题目大意:前面那道题类似,求多个字符串的最长且字典序最小的公共子串,还是枚举子串,然后拿去和剩余主串匹配,保存最优解。代码:#include<iostream>#include<cstdio>#include<cstring>using namespace std;cons...

2012-06-24 14:10:00 112

[树状数组]HOJ 10069 星星的等级

传送门:http://acm.hnu.cn/online/?action=problem&type=show&id=10069&courseid=0题目描述:给定若干个二维平面上 的点,如果a.x<=b.x&&a.y>=b.y则说a的等级比b高(如果a==b,则他们等级相同),要求对于每个点,输出比他等级高的点的总数。解题思路:把星星按照...

2012-06-23 23:39:00 215

VC中Error spawning cl.exe错误的解决方法.

转自:http://blog.csdn.net/badboyfind/article/details/1816189自己的话:由于要做软件二的实验,很多同学问我为什么自己的VC6.0老是不能正常编译,所以贴过来,免得屡次回答,以下是原文。可能很多人在安装VC 6.0后有过点击“Compile”或者“Build”后被出现的 “Compiling... ,Error spawnin...

2012-06-23 22:03:00 221

[KMP或者暴力]POJ 3080 Blue Jeans

传送门:http://poj.org/problem?id=3080题目大意:给定M个字符串(2<=M<=10),长度不超过60个字符,要求求出他们的最长公共子串,如果存在多个解,输出字典序最小的,如果该子串长度小于3,输出no ....(见题目描述)思路:枚举某一个字符串的所有子串,拿去和剩余的所有字符串匹配,保存长度最大且字典序最小的即可,无所谓用KMP,暴力就行了,算法的...

2012-06-23 21:58:00 131

[KMP-NEXT数组性质]POJ 2752 Seek the Name, Seek the Fame

传送门:http://poj.org/problem?id=2752题目描述:要求求出字符串S所有满足如下条件的子串长度(1.子串T为S的前缀 2.子串T为S的后缀)。解题思路:利用KMP的NEXT数组的特性,Next[pos]的含义是在pos处失配时pos应该指向的下一个位置,那么0-(Next[pos]-1)构成的字符串和(pos-Next[pos])-(pos-1)构成的字符串是相同...

2012-06-23 18:12:00 120

[KMP求模式在主串出现次数]POJ 3461 Oulipo

传送门:http://poj.org/problem?id=3461题目大意:给定一个主串和一个模式,求模式在主串中出现的次数。解题思路:直接修改标准KMP函数,当匹配成功是不是跳出循环,而是直接按最后一个字符失配的情况去滑动模式串,以获取下一个可能出现的匹配。代码:#include<iostream>#include<cstring>#inclu...

2012-06-23 17:14:00 203

[KMP求最小周期]POJ 2406 Power Strings

传送门:http://poj.org/problem?id=2406题意:给定一个字符串,让你求出他最多由几个相同的连续子串连接而成。思路:求出这个字符串的最小周期,然后用总长度/最小周期长度即是解。关于如何求最小周期:这里YY了一个方法,就是把该字符串增长一倍,然后拿原来的字符串做模式,增长后的字符串做主串,用KMP求模式在主串第1个位置(下标为0,包含第一个位置)之后的第一个匹配位...

2012-06-23 13:01:00 153

[KMP模板题]HDU-1711 Number Sequence

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1711题意:裸的模式匹配问题,N值较大,必须使用线性算法,考虑上KMP。关于KMP:好久之前就看过KMP不过一直没搞懂,最近要搞下字符串,所以先拿它开刀,翻看了严蔚敏老师的数据结构,研究了许久,算是对KMP略知一二了吧,其KMP主算法还是比较好理解来的(不回溯主串匹配指针,当失配时,利用已经匹...

2012-06-22 23:17:00 179

[线段树]LightOJ 1093 - Ghajini

1093 - GhajiniPDF (English)StatisticsForumTime Limit:1 second(s)Memory Limit:32 MBAmir is having a short term memory problem. He can't remember anything for more thandmil...

2012-06-22 10:41:00 96

[线段树+离散化]LightOJ 1089 - Points in Segments (II)

题目描述:Givennsegments (1 dimensional) andqpoints, for each point you have to find the number of segments which contain that point. A pointpiwill lie in a segmentA BifA ≤ pi≤ B.For example, if the ...

2012-06-22 10:38:00 118

[线段树|平衡树|树状数组]LightOJ - 1087 - Diablo

1087 - DiabloPDF (English)StatisticsForumTime Limit:2 second(s)Memory Limit:64 MBAll of you must have played the game 'Diablo'. It's an exclusive game to play. In this ga...

2012-06-21 00:57:00 138

在Adobe Reader里添加书签功能

转载自:http://hi.baidu.com/%C4%CE%CF%A3nice/blog/item/d24c1202d20dc0e509fa934e.htmlPDF文件的官方阅读程序“Adobe Acrobat Reader”不支持自定义“书签”<nobr style="line-height:18.99pt; color:rgb(102,0,255); border-bottom-c...

2012-06-20 09:30:00 262

MSDN 下载

转载自:http://hi.baidu.com/horse789/blog/item/2413d222f3ba604093580721.htmlMSDN for VC6.0 简体中文版下载2010-09-07 15:07MSDN CD1:ed2k://|file|%5BMicrosoft.Visual.Studio6.0.MSDN.Li...

2012-06-20 00:24:00 230

[搜索]USACO-1.5-Prime Palindromes

Prime PalindromesThe number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all p...

2012-06-19 21:38:00 100

[搜索]USACO-1.4-Packing Rectangles

Packing RectanglesIOI 95The six basic layouts of four rectanglesFour rectangles are given. Find the smallest enclosing (new) rectangle into which these four may be fitted without overlappin...

2012-06-19 01:12:00 104

大数模板

该模板来自于吉林大学ACM模板库#include<iostream>using namespace std;const int base = 10000;const int width = 4;const int N = 1000;struct bint{ int ln,v[N]; bint(int r=0){ for(ln = 0;...

2012-06-13 12:08:00 62

关于代码、

昨天去图书馆借了一本C++代码风格的书,稍微浏览了一下,上面讲了很多写代码的基本原则。于是,拿自己现在写的代码和以前写的代码比较了一下下,发现以前的是非常非常猥琐,现在的是非常猥琐。嗯,说明还是有进步的,本人还能救。...

2012-06-12 10:20:00 78

[BST-SBT]POJ_3481_double queue

题意:裸的平衡树题平衡树功能:插入,删除最大,删除最小挂一个SBT模板吧,明天就校赛了,所以重写了一下SBT,把原来的删除操作改了下:#include<iostream>#include<cstdio>using namespace std;const int MAXN = 1111111,INF = 10000001;struct Key{ ...

2012-05-27 00:38:00 81

[第2短路变形]LightOJ 1099 - Not the Best

1099 - Not the BestPDF (English)StatisticsForumTime Limit:2 second(s)Memory Limit:32 MBRobin has moved to a small village and sometimes enjoys returning to visit one of h...

2012-05-25 01:37:00 205

[第K短路]POJ_2449_Remmarguts' Date

这里的第K短路的定义是:1.如果起点终点相同,那么0并不是最短路,而是要出去一圈回来之后才是最短路,那么第K短路也是一样。2.每个顶点和每条边都可以使用多次。(可以存在环和来回走)然后求K短路使用A*算法,其估价函数f(n) = g(n)+h(n),h(n)是终点到结点n的最短路径,g(n)是起点到结点n的实际代价, 这样选择显然能满足A*估价函数的要求,g(n)>=g'(n...

2012-05-25 01:32:00 74

[最短路+水题]LightOJ 1019 - Brush (V)

求最短路。。。 要多水就有多水,刷水的感觉很差,很少用SPFA,所以算是练习下SPFA把。。传送门:http://lightoj.com/volume_showproblem.php?problem=1019#include<iostream>#include<queue>#include<cstring>#include<alg...

2012-05-24 01:26:00 87

【转】北京大学ACM题目算法分析推荐 acm解决方法

一.动态规划参考资料:刘汝佳《算法艺术与信息学竞赛》《算法导论》推荐题目:http://acm.pku.edu.cn/JudgeOnline/problem?id=1141简单http://acm.pku.edu.cn/JudgeOnline/problem?id=2288中等,经典TSP问题http://acm.pku.edu.cn/JudgeOnline/pr...

2012-05-24 01:01:00 116

[强连通分量]LightOJ 1210 - Efficient Traffic System

传送门:http://lightoj.com/volume_showproblem.php?problem=12101210 - Efficient Traffic SystemPDF (English)StatisticsForumTime Limit:2 second(s)Memory Limit:32 MBI was...

2012-05-24 00:55:00 121

[最小点基]LightOJ 1034 - Hit the Light Switches

传送门:http://lightoj.com/volume_showproblem.php?problem=10341034 - Hit the Light SwitchesPDF (English)StatisticsForumTime Limit:2 second(s)Memory Limit:32 MBRonju is a ...

2012-05-22 01:14:00 150

TopCoder SRM 543 DIV2

昨天熬夜做了人生的第二场SRM,还是有所收获的,总结总结。250:超级简单的题,读懂题意就基本上出来了。500:一道考异或操作的题,给定一个整数区间[L,R],要求计算L XOR L+1 XOR L+2 XOR ...... XOR R 的值,L,R可以在1-4000000000的范围内。乍一看,模拟肯定会超时的,于是分解吧,分解成二进制数,根据XOR的性质来看看是否能...

2012-05-20 12:39:00 100

图论知识点

转自:http://hi.baidu.com/acmjordan/blog/item/3fd0bcc9f7f4605c0fb345dd.html供自己看以及训练:路径问题 0/1边权最短路径 BFS非负边权最短路径(Dijkstra)可以用Dijkstra解决问题的特征负边权最短路径 Bellman-Ford Bellman-Ford的Yen-氏优化...

2012-05-19 23:22:00 187

[线段树+区间求和]LightOJ 1183 - Computing Fast Average

题目链接:http://lightoj.com/volume_showproblem.php?problem=11831183 - Computing Fast AveragePDF (English)StatisticsForumTime Limit:2 second(s)Memory Limit:64 MBGiven a...

2012-05-18 09:21:00 85

[离散化+扫描线+线段树]LightOJ 1120 - Rectangle Union

传送门:http://lightoj.com/volume_showproblem.php?problem=11201120 - Rectangle UnionPDF (English)StatisticsForumTime Limit:2 second(s)Memory Limit:64 MBGiven some axis ...

2012-05-18 01:52:00 91

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除