数据结构
文章平均质量分 53
数据结构
对你说的对
这个作者很懒,什么都没留下…
展开
-
HDU6356 Glad You Came(线段树)
题目链接输入n,m,x,y,z。根据题目中给出的程序,可以得到f数组。a数组初始值全为0,根据题意,对a数组进行m次修改。修改为,l,r区间内比v小的数均改为v。思路: 维护区间的最小值和次小值,lazy更新。 线段树不会超时,大概是因为神奇的随机数。#include<bits/stdc++.h>using namespace std;typedef...原创 2018-08-06 19:19:20 · 169 阅读 · 0 评论 -
HDU 6315 Naive Operations(线段树)
题目链接 两个序列,a序列初始全为0,b序列初始值已知,a、b序列的元素个数相同。add操作,给a序列指定区间元素;query操作,求指定区间a[i]/b[i]向下取整的和。思路: 维护区间的a的最大值和b的最小值,使用lazy标记就不需要更新到每个点了。每次更新当当前最大值a小于最小的b,那么下面子节点就都不需要查询了 大于时我们暴力找到l==r然后cnt+1,同时分母+...原创 2018-07-27 20:35:03 · 216 阅读 · 1 评论 -
HDU 5306 Gorgeous Sequence(线段树)
题目链接 对区间进行操作。 0 x y t :对x到y区间进行操作,将所有大于t的值替换为t。 1 x y:求该区间的最大值。 2 x y:求该区间的和。 思路: 时间复杂度主要高在操作0上,一个一个地更改一定会超时。 维护区间的最大值,次大值,最大值的个数,区间和,通过比较判断最大值和次大值与t的大小关系,进行更新,直接更新t值影响后的区间最大值、次大值...原创 2018-07-18 22:03:21 · 218 阅读 · 0 评论 -
HDU BillBoard(线段树)
Problem DescriptionAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements原创 2017-09-20 21:15:12 · 237 阅读 · 0 评论 -
2018牛客多校训练---farm(二维树状数组)
链接:https://www.nowcoder.com/acm/contest/140/J来源:牛客网题目描述White Rabbit has a rectangular farmland of n*m. In each of the grid there is a kind of plant. The plant in the j-th column of the i-th row...原创 2018-07-22 23:37:05 · 358 阅读 · 0 评论 -
2018牛客多校训练--Different Integers(树状数组)
链接:https://www.nowcoder.com/acm/contest/139/J来源:牛客网题目描述Given a sequence of integers a1, a2, ..., an and q pairs of integers (l1, r1), (l2, r2), ..., (lq, rq), find count(l1, r1), count(l2, r2),...原创 2018-07-20 11:05:19 · 305 阅读 · 0 评论 -
HDU 4267 A Simple Problem With Integers(树状数组)
Problem DescriptionLet A1, A2, ... , AN be N elements. You need to deal with two kinds of operations. One type of operation is to add a given number to a few numbers in a given interval. The other i原创 2017-09-30 16:37:29 · 229 阅读 · 0 评论 -
Flowers(树状数组)
Problem DescriptionAs is known to all, the blooming time and duration varies between different kinds of flowers. Now there is a garden planted full of flowers. The gardener wants to know how many fl原创 2017-09-25 22:44:52 · 497 阅读 · 0 评论 -
HDU find the nondecreasing subsequences(树状数组)
Problem DescriptionHow many nondecreasing subsequences can you find in the sequence S = {s1, s2, s3, ...., sn} ? For example, we assume that S = {1, 2, 3}, and you can find seven nondecreasing subse原创 2017-08-21 21:46:30 · 159 阅读 · 0 评论 -
HDU 1892 see you(二维树状数组)
Now I am leaving hust acm. In the past two and half years, I learned so many knowledge about Algorithm and Programming, and I met so many good friends. I want to say sorry to Mr, Yin, I must leave now原创 2017-08-21 21:42:58 · 239 阅读 · 0 评论 -
POJ a simple problem of Integers(树状数组)
DescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is原创 2017-08-20 21:35:39 · 226 阅读 · 0 评论 -
POJ Ultra-QuickSort(树状数组)
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequenc原创 2017-08-20 21:30:32 · 253 阅读 · 0 评论 -
HZAU 1206 MathematicalGame(字典树)
题目链接Description Xiao Ming likes to play mathematical games very much. One day, he gets a sequence of n positive integers. XOR (l , r) is defined as the XOR and of all numbers in a continuous i...原创 2018-09-30 09:56:24 · 234 阅读 · 0 评论 -
HDU 5536 Chip Factory(字典树)
题目链接给N个数,找出(a[i]+a[j])^a[k]的最大值,其中i,j,k,为不同的数。用01字典树求解。#include<bits/stdc++.h>using namespace std;const int maxn=1e3+3;int arr[maxn],cnt;struct Node{ int a[2],sum;//a数组当前值存的是0还...原创 2018-09-29 22:26:19 · 119 阅读 · 0 评论 -
UVA1401 - Remember the Word(字典树+DP)
Time limit: 3.000 secondsNeal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal gi...原创 2018-08-24 09:46:40 · 213 阅读 · 0 评论 -
HDU2586 How far away ?(树上倍增求LCA)
题目链接Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25284 Accepted Submission(s): 10051Problem DescriptionThere are n houses in the vi...原创 2018-11-09 21:47:00 · 303 阅读 · 0 评论 -
最近公共祖先LCA---在线倍增算法
在线求LCA,多次询问。倍增算法时间复杂度为。 1、dfs求每个节点所在层数void dfs(int u,int root,int d){ int i; depth[u]=d; fa[u][0]=root;//初始化 int sz=edge[u].size(); for(i=0;i<sz;i++) { int ...原创 2018-11-09 21:40:25 · 236 阅读 · 0 评论 -
HDU6290 奢侈的旅行(堆优化的迪杰斯特拉算法)
题目链接 Time Limit: 14000/7000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 1643 Accepted Submission(s): 336 Problem Description高玩小Q不仅喜欢玩寻宝游戏,还喜欢一款升级养成...原创 2018-11-12 09:38:26 · 284 阅读 · 0 评论 -
HDU6386 Age of Moyu(BFS)
题目链接一个图n个点,m条边。在一条路上,如果连续路径上的权值相同,那么花费1就可以到达,例1-1-1三条路,四个点,这四个点互通都只花费1.例1-2-1三条路,四个点,从第一个点到第四个点花费为3(权值修改了三次)。思路: bfs查询路径,每条路都只走一次。每一个点入队列后,再用dfs把所有与当前路径相同权值的路径加入。本质上是记录依次花费1,2,....步能到达哪里。bfs先查...原创 2018-08-13 21:52:32 · 755 阅读 · 0 评论 -
HDU 5371 Hotaru's problem(Manacher算法)
题目链接#include<bits/stdc++.h>using namespace std;const int N=100100;int str[N*2],tmp[N*2];int len[N*2],n;//len[i]:扩展后字符串以i为中心最长回文串的半径。void init(){ int i; tmp[0]=-2; fo...原创 2018-08-07 10:04:49 · 115 阅读 · 0 评论 -
POJ3974 Palindrome(Manacher算法)
Manacher算法详解https://blog.csdn.net/dyx404514/article/details/42061017题目链接求最长回文串长度,manacher算法模板题。#include<bits/stdc++.h>using namespace std;const int N=1000010;char str[N],tmp[N&l...原创 2018-08-06 10:57:09 · 159 阅读 · 0 评论 -
HDU5326 Work(并查集+思维题)
题目链接 一个公司n个人,n-1中直接上下级关系,问有多少人恰好管着k个人包括(直接管理和间接管理)。 思路:数据范围较小,直接查找即可。#include<bits/stdc++.h>using namespace std;const int N=110;int n,k;int fa[N],sum[N];void Find(int x){ w...原创 2018-07-20 22:59:18 · 117 阅读 · 0 评论 -
2018牛客多校训练---Sort String(KMP算法)
链接:https://www.nowcoder.com/acm/contest/141/E来源:牛客网题目描述Eddy likes to play with string which is a sequence of characters. One day, Eddy has played with a string S for a long time and wonders how...原创 2018-07-26 20:48:06 · 378 阅读 · 0 评论