
ACM_数据结构
文章平均质量分 78
HQD因为有趣所以做题
这个作者很懒,什么都没留下…
展开
-
HDU 4107
线段树的题目#include #define LL(x) x << 1#define RR(x) x << 1 | 1const int MAXN = 200000 + 123;struct NODE{ int l, r, rmax, rmin; int lazy; int mid() { return (l + r) >> 1;原创 2012-02-25 19:35:40 · 1326 阅读 · 0 评论 -
Codeforces Beta Round #75 Igloo Skyscraper
很不错的一道线段树的题目在每个节点里面加个线性表,这是关键的操作!线性表里面是这个节点的范围内,将它按照a数组从小到大排序,接着剔除掉a[i] >= a[j] 并且b[i] >= b[j]这种j另外还要用到(a[x] - a[y])*(b[z]-b[y原创 2011-10-02 11:28:13 · 1115 阅读 · 0 评论 -
SPOJ 1793. Text Generater II
AC自动机+矩阵乘法+容斥原理刚开始是用单纯的状态压缩,当然是TLE后来用容斥原理,接着几乎快了64倍还多,接着各种弄,就过了2.99S,不知道那些弄到0.05秒的神牛怎么弄的原创 2011-10-01 19:43:39 · 1158 阅读 · 1 评论 -
hdu 3584 Cube //三维树状数组
由二维的推一下就好了注意一下三维空间的容斥性,更新的时候注意一下这是区间更新,单点查询仔细想一想为什么可以这么做 Add(x1, y1, z1, 1); Add(x2+1, y1,原创 2011-09-06 11:23:04 · 1001 阅读 · 0 评论 -
hdu 4008 Parent and son
/*首先以1为根,扫描一遍树,得到每个节点的minchild[i][2],儿子节点的最小值和次小值(不同子树的)和每个节点的最小后缀的值mindown[i](1)如果x是y的父节点的话,那么直接输出mindown[i],minchild[i][0]即可(2)如果y是x的父原创 2011-09-05 16:25:32 · 3249 阅读 · 0 评论 -
hdu 4000 Fruit Ninja
小大中+小中大= ?#include #include const int MAXN = 100000 + 1234;const int mod = 100000007;int n;long long tree[MAXN];long long ans[MAXN原创 2011-09-01 20:50:02 · 1126 阅读 · 0 评论 -
hdu 3333 Turing Tree
按右端点排序#include #include #include using namespace std;const int MAXN = 50010;const int MAXM = 200000 + 123;struct Edge{ int id,原创 2011-08-29 22:32:12 · 934 阅读 · 0 评论 -
hdu 3627 Giant For //线段树
首先以x为第一关键字,y为第二关键字进行排序,离散化得到一个长度为num的数组(任何一次查询对应的点都能在这个数组中找到)对此进行建树比如进行第i次操作找到其在数组中对应的点pos那么pos--->num这里面的所有点的x值都大于等于pos点看这一段序列是原创 2011-08-29 15:37:43 · 1068 阅读 · 0 评论 -
hdu 3954 Level up
操作十分不同,很特别比赛的时候没想出来,好好总结吧原创 2011-08-22 18:43:29 · 946 阅读 · 0 评论 -
hdu 3689 Infinite monkey theorem
去年杭州区域赛的一道题目,比较简单的AC自动机#include #include const int NODE = 1000;const int CH = 26;int tree[NODE][CH], cnt;int fail[NODE], word[NOD原创 2011-08-15 17:56:57 · 1333 阅读 · 0 评论 -
hdu 3911 简单线段树
#include #include #include using namespace std;#define LL(x) (x << 1)#define RR(x) (x << 1) | 1const int MAXN = 100000;struct Seg_T原创 2011-08-07 11:13:07 · 808 阅读 · 0 评论 -
hdu 3397
前天比赛遇到一道简化版的抑或的线段树,比赛调了一个点才过这道题是上次的增强版#include #include #include using namespace std;#define LL(x) (x << 1)#define RR(x) (x <<原创 2011-08-06 12:17:23 · 1353 阅读 · 0 评论 -
NOI 2010 超级钢琴
晚上发现NOI不给用优先级队列,就自己写个堆,还行,速度#include const int N = (500000 + 1234) * 2;struct heap_node{ int value, l, r, minv, loc; heap_原创 2011-08-03 23:01:39 · 1629 阅读 · 0 评论 -
hdu 3635 Dragon Balls
虽然不难,但是很讲究是否理解了并查集的实质#include #include const int MAXN = 10000 + 1234;int n, q;int con[MAXN];int p[MAXN];int num[MAXN];int find(原创 2011-08-01 11:04:26 · 1008 阅读 · 0 评论 -
BUPT 203 Palindrome
后缀数组变了个行就傻眼了。。。前面求出每个点为中心的最长回文字,接着对于一个[l,r]的查询,有两种二分方法第一是left = 1, right = r - l + 1, mid = (l+ r ) >>1, 对于[l+mid-1,r-mid+1]这个区间用RMQ求出一个最大值P原创 2011-07-22 16:17:48 · 578 阅读 · 0 评论 -
BUPT 201 Glorious Array
北邮邀请赛的题目,比赛的时候思路很乱,现在整理下吧。网上已经给出了有公式解法,我这里还是说说树状数组的解法吧题目只有两个操作,一个是将一个点的颜色取反,一个是询问有多少个端点颜色不同并且包含小于k的区间。总体思路是这样首先是用树状数组保存每个点的颜色,如果是1,那个点加1,这是初原创 2011-07-22 09:32:49 · 517 阅读 · 0 评论 -
HDU 3474 Necklace //单调队列
#include #include const int MAXN = 1000000 + 123;struct node{ int id, val; node(int x, int y): id(x), val(y) {} node(){}}q[原创 2011-07-20 11:29:04 · 688 阅读 · 0 评论 -
hdu 3530 Subsequence //单调队列
#include #include #include using namespace std;const int MAXN = 100000 + 123;struct node{ int id, val; node(int x, int y): id(原创 2011-07-20 09:34:45 · 914 阅读 · 0 评论 -
hdu 3415 Max Sum of Max-K-sub-sequence
#include #include const int MAXN = 100000 + 123;struct node{ int id, val; node(int x, int y): id(x), val(y) {} node() {}} q原创 2011-07-18 15:00:28 · 728 阅读 · 0 评论 -
2823 Sliding Window //单调队列
Sliding WindowTime Limit: 12000MS Memory Limit: 65536KTotal Submissions: 18639 Accepted: 5331Case Time Limit: 5000MSDescriptionAn array of s原创 2011-07-18 10:52:27 · 518 阅读 · 0 评论 -
hdu 1890 Robotic Sort //splay tree
/*这题因为不是对数列第K个,而是对初始化标记的序号操作,所以标记的处理很不一般*/#include #include #include using namespace std;const int MAXN = 100000 + 123;const int INF原创 2011-07-11 17:06:17 · 836 阅读 · 0 评论 -
spoj 1470 //splay tree
1470. Another Sequence ProblemProblem code: SEQ2You are to write a program to perform some operations on a given sequence.These operations a原创 2011-07-10 23:22:02 · 880 阅读 · 0 评论 -
【HNOI2002】营业额统计 //SPLAY TREE
#include const int MAXN = 100001;const int INF = 1 << 30;struct NODE{ int c[2], p, v, mul, sz; bool d;}T[MAXN];int n原创 2011-07-05 14:40:22 · 1094 阅读 · 0 评论 -
【NOI2004】郁闷的出纳员 // SPLAY TREE
#include #include const int MAXN = 100001;const int INF = 1 << 30 ;struct Node{ int c[2], p, v, mul, sz; bool d;}T[M原创 2011-07-05 10:45:53 · 1180 阅读 · 0 评论 -
poj 1625 Censored!//AC自动机+DP+大数
Censored!Time Limit: 5000MS Memory Limit: 10000KTotal Submissions: 3608 Accepted: 999DescriptionThe alphabet of Freeland consists of exactly N letters. Each sentence of Freeland language (also known as Freish) consists of exactly M letters without word br原创 2011-04-28 19:31:00 · 1627 阅读 · 1 评论 -
hdu 2243 考研路茫茫——单词情结 //AC自动机
<br /> <br />考研路茫茫——单词情结Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 520 Accepted Submission(s): 143<br /><br /><br /><br />#include<cstdio>#include<cstring>typedef unsigned __int64 ul原创 2011-04-26 21:05:00 · 1566 阅读 · 0 评论 -
poj 2778 DNA Sequence //AC自动机+矩阵乘法
DNA SequenceTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5080 Accepted: 1766DescriptionIt's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For example, if a ani原创 2011-04-22 21:59:00 · 1430 阅读 · 0 评论 -
hdu 3065 病毒侵袭持续中 //AC自动机
<br /> <br />病毒侵袭持续中Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 866 Accepted Submission(s): 293<br /><br /><br />Problem Description小t非常感谢大家帮忙解决了他的上一个问题。然而病毒侵袭持续中。在小t的不懈努力下,他发现了网路中的“万恶之源”原创 2011-04-21 19:26:00 · 913 阅读 · 0 评论 -
hdu 2896 病毒侵袭 //AC自动机
<br /> <br />病毒侵袭Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 1621 Accepted Submission(s): 423<br /><br /><br />Problem Description当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻。。。。在这样的时刻,人们却异常兴奋——我们能在有原创 2011-04-21 18:09:00 · 1618 阅读 · 0 评论 -
hdu 2222 Keywords Search //ac自动机
<br />Keywords SearchTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 7476 Accepted Submission(s): 2541<br /><br /><br />Problem DescriptionIn the modern time, Search engine came into the life原创 2011-04-21 09:05:00 · 1169 阅读 · 0 评论 -
poj 3294 Life Forms
<br />Life FormsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 4628 Accepted: 1207<br />Description<br />You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles原创 2011-04-19 15:22:00 · 1557 阅读 · 0 评论 -
poj 3415 Common Substrings
<br />Common SubstringsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 3112 Accepted: 1002<br />Description<br />A substring of a string T is defined as:<br /> T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|.<br /> <br />Given two strings A, B and one i原创 2011-04-18 21:09:00 · 1211 阅读 · 1 评论 -
poj 3693 Maximum repetition substring //后缀数组
<br />Maximum repetition substringTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2233 Accepted: 547<br />Description<br />The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same co原创 2011-04-16 09:30:00 · 1515 阅读 · 0 评论 -
spoj 687 Repeats//后缀数组
SPOJ Problem Set (classical)687. RepeatsProblem code: REPEATSA string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the strings = abaabaabaabais a (4,3)-repeat with t = aba as its原创 2011-04-15 21:42:00 · 1448 阅读 · 0 评论 -
timus 1517 Freedom of Choice//后缀数组
<br />1517. Freedom of ChoiceTime Limit: 2.0 second<br />Memory Limit: 32 MBBackgroundBefore Albanian people could bear with the freedom of speech (this story is fully described in the problem "Freedom of speech"), another freedom - the freedom of choice -原创 2011-04-15 19:35:00 · 1109 阅读 · 0 评论 -
poj 2406 Power Strings //DC3 后缀数组
<br /> Power StringsTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 16624 Accepted: 6923<br />DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think o原创 2011-04-15 08:51:00 · 987 阅读 · 0 评论 -
timus 1297 Palindrome//后缀数组,求最长公共回文字
<br /> <br />1297. PalindromeTime Limit: 1.0 second<br />Memory Limit: 16 MBThe “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent from the competing «Robots Unlimited» has infiltrated into “U.S. Robotics”. «U.S原创 2011-04-14 21:07:00 · 733 阅读 · 0 评论 -
poj 3368 Frequent values //RMQ
<br /> Frequent valuesTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 7310 Accepted: 2617<br />Description<br />You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries原创 2011-04-14 20:27:00 · 666 阅读 · 0 评论 -
poj 3368 Frequent values //线段树
<br /> Frequent valuesTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 7308 Accepted: 2615<br />Description<br />You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries原创 2011-04-14 20:09:00 · 794 阅读 · 0 评论 -
3264 Balanced Lineup //rmq
<br />Balanced LineupTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 16743 Accepted: 7758Case Time Limit: 2000MS<br />Description<br />For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer J原创 2011-04-14 18:51:00 · 517 阅读 · 0 评论