数据结构
sigh_
这个作者很懒,什么都没留下…
展开
-
ZOJ_3199 Longest Repeated Substring(后缀数组+ST表)
Longest Repeated SubstringTime Limit: 5000 msMemory Limit: 32768 KBProblem DescriptionWrite a program that takes a string and returns length of the longest repeated substring. A repeated substring is a sequence of characters that is immediately followe原创 2020-12-06 18:03:26 · 132 阅读 · 0 评论 -
洛谷_1382 楼房(线段树)
楼房题目链接:https://www.luogu.com.cn/problem/P1382题解:假设初始在点(-INF,0),那么之后的每次都可以看做一次水平移动加上一次垂直移动。类似于扫描线,将线段分为两部分,左端点为入,右端点为出。线段树维护最大值。将x坐标相同的作为一组。若当前点为左端点,则在线段树中加上h的信息,为右端点,则在线段树中删去h的信息。 最后求出当前h的最大值,即为yy, 此时的x轴坐标为xx。设上次移动后,点为(x,y)。若yy!=yyy!=yyy!=y,则在答案中加入(xx,原创 2020-11-15 20:40:25 · 255 阅读 · 0 评论 -
Gym_102452I Incoming Asteroids(数据结构)
Incoming Asteroidstime limit per test:2 secondsmemory limit per test:512 megabytesProblem DescriptionThe International Coalition to Prevent Catastrophes (ICPC) recently discovered several small asteroids in a nearby galaxy. If these asteroids hit the E原创 2020-10-31 10:17:48 · 685 阅读 · 0 评论 -
HDU_5381 The sum of gcd(数论+线段树)
The sum of gcdTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionYou have an array A,the length of AAA is nnnLet f(l,r)=∑i=lr∑j=ijgcd(ai,ai+1,...,aj)f(l,r)=\sum_{i=l}^r\sum_{j=i}^jgcd(a_i,a_{i+1},...,原创 2020-10-09 16:12:48 · 151 阅读 · 0 评论 -
POJ_3694 Network(并查集+DFS)
NetworkTime Limit: 5000MS Memory Limit: 65536KProblem DescriptionA network administrator manages a large network. The network consists of N computers and M links between pairs of computers. Any pair of computers are connected directly or indirectly by原创 2020-09-18 11:42:25 · 124 阅读 · 0 评论 -
CodeForces_1418D Trash Problem(数据结构)
Trash Problemtime limit per test:3 secondsmemory limit per test:256 megabytesProblem DescriptionVova decided to clean his room. The room can be represented as the coordinate axis OX. There are n piles of trash in the room, coordinate of the iii-th pile原创 2020-09-15 11:31:00 · 194 阅读 · 0 评论 -
POJ_1990 MooFest(树状数组)
MooFestTime Limit: 1000MS Memory Limit: 30000KProblem DescriptionEvery year, Farmer John’s N (1 <= N <= 20,000) cows attend “MooFest”,a social gathering of cows from around the world. MooFest involves a variety of events including haybale stacki原创 2020-09-02 22:31:09 · 144 阅读 · 0 评论 -
ZOJ_3724 Delivery(线段树)
DeliveryTime Limit: 6000 msMemory Limit: 65536 KBProblem DescriptionKarl is an impatient guy. He always wants to find the fastest way to solve any problem. As a delivery man, it’s a very good personality because he can make the work more efficient.Now原创 2020-07-14 09:46:20 · 156 阅读 · 0 评论 -
洛谷_1110 报表统计(线段树)
报表统计题目链接:https://www.luogu.com.cn/problem/P1110题解:考虑离散化,利用两颗线段树来维护合适的信息求解两个询问。MIN_GAP:求相邻的差值绝对值最小。建立线段树存储差值的出现次数,询问时求差值最小的那个即可。记位置iii初始值为a[i]a[i]a[i],新插入的值为b[i]b[i]b[i](初始b[i]=a[i]b[i]=a[i]b[i]=a[i]),当在位置iii插入一个新的数kkk时,原本的差值abs(a[i+1]−b[i])abs(a[i+1]-b原创 2020-06-19 17:31:41 · 208 阅读 · 0 评论 -
洛谷_2495 [SDOI2011]消耗战(虚树)
消耗战题目链接:https://www.luogu.com.cn/problem/P2495题解:对于单样例,可以考虑树形DP。但此题是多实例,所以需要对树进行处理,每次询问有k+1(加上一号点)个关键点。对每个询问构造出虚树。边权:虚树的边上的权值,为原树中两点路径上的边权最小值,可以利用倍增的思想求权值。DP:对于虚树,设dpidp_idpi为以iii为根的子树都与i号节点断开连...原创 2020-04-21 17:49:13 · 169 阅读 · 0 评论 -
CodeForces_613D Kingdom and its Cities(虚树)
Kingdom and its Citiestime limit per test:2 secondsmemory limit per test:256 megabytesProblem DescriptionMeanwhile, the kingdom of K is getting ready for the marriage of the King’s daughter. Howev...原创 2020-04-21 14:33:45 · 182 阅读 · 0 评论 -
51nod_2361 XYK的音游(动态规划)
XYK的音游Problem Descriptionxyk最近入坑了一个新音游。游戏界面上有 nnn 个并排的按键,当前这首歌有 mmm 个鼓点。游戏的玩法是在鼓点的时刻移动鼠标到对应的按键上并点击来获取分数。对于第 i 个鼓点,我们用tit_iti,wiw_iwi,xix_ixi 来描述,表示在tit_iti 时刻点击第 xix_ixi 个按键会获得 wiw_iwi 的分数。...原创 2020-04-16 21:07:01 · 261 阅读 · 0 评论 -
51nod 双重祖先(启发式合并)
双重祖先Problem Description给定两棵有根树,两棵树均有n个节点,且根均为1号点。问有多少对(u,v)满足:在给定的两棵树中u均为v的祖先。Input本题中每个测试点仅包含一组测试数据第一行一个正整数n,表示树的规模接下来的n-1行,每行两个整数x, y,表示在第一棵有根树中x点与y点之间有一条连边。再接下来的n-1行,每行两个整数x, y,表示在第二棵有根树...原创 2020-03-30 15:15:19 · 367 阅读 · 0 评论