
数据结构
文章平均质量分 72
hehedad
这个作者很懒,什么都没留下…
展开
-
洛谷多校 - Earthquake(线段树)
线段树维护,三个lazy数组表示这个区间分别有个从右到左,全部,从左到右的数据覆盖。#include<bits/stdc++.h>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int N = 5e5 + 10;i...原创 2020-03-31 14:11:05 · 268 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3) F Moving Points(离散化+树状数组)
F. Moving Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere arennpoints on a coordinate axisOXOX. Theii-th point i...原创 2020-02-24 23:51:10 · 539 阅读 · 0 评论 -
HDU - 6638 Snowy Smile(枚举+线段树维护最大连续区间和)
There arennpirate chests buried in Byteland, labeled by1,2,…,n1,2,…,n. Theii-th chest's location is(xi,yi)(xi,yi), and its value iswiwi,wiwican be negative since the pirate can add some poison...原创 2019-08-13 21:16:16 · 279 阅读 · 0 评论 -
2019牛客暑期多校训练营(第七场) E Find the median(线段树)
链接:https://ac.nowcoder.com/acm/contest/887/E来源:牛客网题目描述Let median of some array be the number which would stand in the middle of this array if it was sorted beforehand. If the array has even len...原创 2019-08-09 15:16:13 · 153 阅读 · 0 评论 -
2019牛客暑期多校训练营(第四场) B Xor(线段树+线性基合并)
链接:https://ac.nowcoder.com/acm/contest/884/B来源:牛客网题目描述Your are given n sets.Every set contains some integers.We say a set can express an integer, only when there exists a subset of the set suc...原创 2019-08-09 15:41:33 · 205 阅读 · 0 评论 -
2019牛客暑期多校训练营(第八场) I Inner World(dfs序+线段树)
链接:https://ac.nowcoder.com/acm/contest/888/I来源:牛客网题目描述Gromah and LZR are transfered to a forest, maybe it is the inner world of the great tomb. Initially, there arenn_{}nrooted trees numbere...原创 2019-08-14 10:26:31 · 252 阅读 · 0 评论 -
2019 CCPC - 网络选拔赛 B array(线段树)
arrayTime Limit: 2000/1500 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 97Accepted Submission(s): 22Problem DescriptionYou are given an arraya1,a2,...原创 2019-08-23 18:37:33 · 398 阅读 · 0 评论 -
2019牛客暑期多校训练营(第九场)E All men are brothers(线段树做法)
链接:https://ac.nowcoder.com/acm/contest/889/E来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述Amy asks Mr. B problem E. Please help Mr. B to solve the followin...原创 2019-08-15 18:42:57 · 197 阅读 · 0 评论 -
2019牛客暑期多校训练营(第九场)H Cutting Bamboos(主席树+二分)
链接:https://ac.nowcoder.com/acm/contest/889/H来源:牛客网题目描述There are n bamboos arranged in a line. The i-th bamboo from the left has height hih_{i}hi.You are given q queries of the type (l, r, x, ...原创 2019-08-15 23:58:50 · 390 阅读 · 0 评论 -
2019牛客暑期多校训练营(第八场) E Explorer(线段树+模拟并查集)
链接:https://ac.nowcoder.com/acm/contest/888/E来源:牛客网题目描述Gromah and LZR have entered the fifth level. Unlike the first four levels, they should do some moves in this level.There are nn_{}n v...原创 2019-08-12 12:55:23 · 201 阅读 · 0 评论 -
HDU - 1542 (扫描线)
AtlantisTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23409Accepted Submission(s): 9267Problem DescriptionThere are several ancie...原创 2019-08-16 17:15:10 · 159 阅读 · 0 评论 -
The beautiful values of the palace 南京网络赛A(主席树)
Here is a square matrix ofn * nn∗n, each lattice has its value (nnmust be odd), and the center value isn * nn∗n. Its spiral decline along the center of the square matrix (the way of spiral decline ...原创 2019-09-01 23:01:51 · 291 阅读 · 0 评论 -
HDU - 5919 (主席树)
Sequence IITime Limit: 9000/4500 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4734Accepted Submission(s): 1329Problem DescriptionMr. Frog has an int...原创 2019-09-26 15:20:41 · 269 阅读 · 0 评论 -
某巨文艺平衡树(Splay模板)
洛谷 P3391/*Splay只记模板是很困难的,而且真正运用时易生疏出错,所以必须理解,在看代码前先弄懂Splay的原理,这篇代码是带注释的Splay模板,题目来自洛谷P3391 ———————————by 520*/#include<bits/stdc++.h>#define il inlineusing namespace std;const int N = 10...原创 2019-10-02 20:56:33 · 197 阅读 · 0 评论 -
CSU - 2170 千万别用树套树(线段树)
链接:https://ac.nowcoder.com/acm/contest/1108/H来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536KSpecial Judge, 64bit IO Format: %lld题目描述Bobo 精通数据结构!他想维护一个线段的集合 S。初始时,S 为空。他会依次进行 q 次操作,操作...原创 2019-10-03 14:46:41 · 210 阅读 · 0 评论 -
POJ - 1816 Wild Words (模糊状态下字典树匹配)
A word is a string of lowercases. A word pattern is a string of lowercases, '?'s and '*'s. In a pattern, a '?' matches any single lowercase, and a '*' matches none or more lowercases.There are many w...原创 2019-10-06 20:39:27 · 259 阅读 · 0 评论 -
POJ - 3764 The xor-longest Path (字典树入门)
In an edge-weighted tree, the xor-length of a pathpis defined as the xor sum of the weights of edges onp:⊕ is the xor operator.We say a path the xor-longest path if it has the largest xor-...原创 2019-10-10 00:46:44 · 209 阅读 · 0 评论 -
HDU - 6621 K-th Closest Distance(主席树+二分)
You have an array: a1, a2, , an and you must answer for some queries.For each query, you are given an interval [L, R] and two numbers p and K. Your goal is to find the Kth closest distance between ...原创 2019-08-06 20:11:54 · 159 阅读 · 0 评论 -
HDU - 6602 Longest Subarray (思维+线段树)
You are given two integersC,KC,Kand an array ofNNintegersa1,a2,...,aNa1,a2,...,aN. It is guaranteed that the value ofaiaiis between11toCC.We define that a continuous subsequenceal,al+1,.....原创 2019-07-31 19:43:23 · 215 阅读 · 0 评论 -
徐州赛区网络赛 Ryuji doesn't want to study(树状数组)
Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i].Unfortunately, the longer he learns, the fewer he gets.That m...原创 2018-09-09 19:28:20 · 305 阅读 · 0 评论 -
沈阳网络赛 J题 Ka Chang (树状数组+dfs序+分块思想)
Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero point.Then, you need to handle QQ operations. There're two types:1\ L\ X1 L X: Increase points by XX of all n...原创 2018-09-11 00:11:07 · 256 阅读 · 0 评论 -
HDU - 5877 Weak Pair (离散化+dfs+树状数组)
Weak Pair Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 5327 Accepted Submission(s): 1543 Problem Description You ...原创 2018-10-01 23:19:32 · 273 阅读 · 0 评论 -
CodeForces - 1042D Petya and Array (树状数组+离散化)
Petya has an array aa consisting of nn integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty ...原创 2018-12-02 20:46:26 · 318 阅读 · 1 评论 -
HDU - 2795 Billboard(线段树)
At 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 are posted: nearest p...原创 2019-01-20 21:24:53 · 125 阅读 · 0 评论 -
POJ - 2828 Buy Tickets (线段树♂的用法)
Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…The Lunar New Year was approaching, but unluckily the Little Cat still had sch...原创 2019-01-21 16:54:06 · 154 阅读 · 0 评论 -
HDU - 3966 Aragorn's Story(树链剖分,树状数组模式)
Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps ou...原创 2019-02-15 15:53:44 · 205 阅读 · 0 评论 -
POJ - 2104 K-th Number(主席树||划分树)
You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quic...原创 2019-03-14 21:30:17 · 177 阅读 · 0 评论 -
SPOJ - DQUERY D-query (主席树)
Given a sequence of n numbers a1, a2, ..., anand a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the ...原创 2019-03-15 21:19:21 · 277 阅读 · 0 评论 -
HDU - 6464 免费送气球 (线段树)
又到了GDUT一年一度的程序设计竞赛校赛的时间啦。同学们只要参加校赛,并且每解出一道题目就可以免费获得由ACM协会和集训队送出的气球一个。听到这个消息,JMC也想参加免费拿气球。可是,由于JMC太菜了而被禁止参赛,于是他找到你想让你帮忙参加比赛,可以通过执行下面的C++程序解决问题后获得气球并送给他。JMC保证了下面的程序一定能获得正确的结果。void solve(int Q, int typ...原创 2019-03-18 19:52:30 · 275 阅读 · 0 评论 -
UVA - 11992(线段树~~顺便吐槽为何我最近总遇到线段树。。。我做腻了)
Fast Matrix OperationsThere is a matrix containing at most 106elements divided into r rows and c columns. Each element has a location (x,y) where 1<=x<=...原创 2019-04-08 20:11:12 · 149 阅读 · 0 评论 -
ZOJ 3998 Yet Another Data Structure Problem(线段树)
有三种操作,区间内每个数数乘一个数,区间内每个数成为他的K次方,求区间内数的乘积。 容易看出这是需要线段树来做的。 我们在这里放置两个lazy数组,用原线段树来维护区间内现在区间乘积是多少。一个lazy数组表示下方未更新的区间需要进行几次方的运算。另一个数组来表示下方为处理区间除了乘方操作外,所有的需要额外的进行乘的数是多少~~。需要注意的是在进行pushdown操作的...原创 2019-04-30 00:54:08 · 159 阅读 · 0 评论 -
GCD Problem (线段树区间GCD+区间开方)
题目描述输入描述:输出描述:输入45 45 20 6571 1 40 1 41 1 41 3 40 3 41 3 41 2 2输出52426 两个操作,一个是区间开方,一个是输出区间GCD;gcd很好处理。主要是开放这个操作,假设区间sum==l-r+1就return,不是的话就取找辣个还不是1的点去单点更新,这样...原创 2019-04-25 18:21:25 · 397 阅读 · 0 评论 -
HDU - 4578 Transformation (线段树)
Yuanfang is puzzled with the question below:There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to each number between a...原创 2019-05-23 14:47:35 · 190 阅读 · 0 评论 -
Rabbit的数列 (线段树 - 利用区间最大值最小值查询某个数的数量)
链接:https://ac.nowcoder.com/acm/contest/907/C来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述Rabbit得到了一个长度为N的数列(数列编号从0到N−1)。数列中每个数vali满足1<=vali<=C。初始时数列...原创 2019-06-01 14:57:51 · 361 阅读 · 0 评论 -
HDU - 6609 Find the answer(线段树)
Given a sequence of n integers called W and an integer m. For each i (1 <= i <= n), you can choose some elements WkWk (1 <= k < i), and change them to zero to make ∑ij=1∑j=1iWjWj<=m. So...原创 2019-07-31 14:52:16 · 367 阅读 · 0 评论 -
HDU - 6447 YJJ's Salesman(树状数组优化的dp+离散化)
YJJ's Salesman Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1996 Accepted Submission(s): 744 Problem Description ...原创 2018-08-31 21:20:42 · 226 阅读 · 0 评论