
树状数组与线段树
文章平均质量分 92
zeng_jun_yv
title:
退役小曾
展开
-
替罪羊树详解
替罪羊树详解刚开始学习平衡树。可是我太弱了弄不懂有旋转操作的treap和splay,这时候学习可以不用旋转操作——替罪羊树的平衡树就很适合。这个名字取得比较玄乎,一眼看上去并不知道有什么卵用,但是, 如果你是刚学平衡树的新手,那么从替罪羊树开始学一定是个绝佳的选择,因为它是个很优雅的平衡树,什么叫优雅?暴力即是优雅!如果在一棵平衡的二叉搜索树内进行查询等操作,时间就可以稳定在log(n),但是...原创 2021-07-14 14:46:26 · 975 阅读 · 0 评论 -
蓝桥杯2014届试题9题 小朋友排队(树状数组+类逆序对)
题目:资源限制时间限制:1.0s 内存限制:256.0MB问题描述n 个小朋友站成一排。现在要把他们按身高从低到高的顺序排列,但是每次只能交换位置相邻的两个小朋友。每个小朋友都有一个不高兴的程度。开始的时候,所有小朋友的不高兴程度都是0。如果某个小朋友第一次被要求交换,则他的不高兴程度增加1,如果第二次要求他交换,则他的不高兴程度增加2(即不高兴程度为3),依次类推。当要求某个小朋友第k次交换时,他的不高兴程度增加k。请问,要让所有小朋友按从低到高排队,他们的不高兴程度之和最小是多少。如原创 2020-10-13 17:08:24 · 166 阅读 · 0 评论 -
Assign the task HDU - 3974(线段树+dfs建树+单点查询+区间修改)
题意:染色问题:给一个固定结构的树,现在有两个操作:(1) y 将结点x及其所有后代结点染成颜色y;(2)查询结点x当前的颜色。其实就是区间染色问题,不过需要dfs预处理,题目:There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you原创 2020-09-25 16:42:05 · 187 阅读 · 0 评论 -
Just a Hook HDU - 1698(查询区间求和+最基础模板)
题意:给你一个1~n的区间,起始区间内均为1,然后对子区间进行值更新,最后求区间和。题目:In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.Now Pudge wants to原创 2020-09-25 11:15:55 · 203 阅读 · 0 评论 -
Balanced Lineup POJ - 3264(线段树模板+查询比大小+建树)
题意:给你n个数,然后问一段区间的最大的差值是多少。题目:For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a c原创 2020-09-25 10:09:08 · 119 阅读 · 0 评论 -
Mayor's posters POJ - 2528 (离散化+线段树)
题意:在1~10000000这个区间中读取n个海报的区间信息,后面的海报会覆 盖前面的海报,问最后能看到几张海报.(本题是一道bug题下面会提)题目:The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing th...原创 2019-08-04 20:56:53 · 182 阅读 · 0 评论 -
A Simple Problem with Integers POJ - 3468(线段树+区间查询+区间修改+建树+懒惰标记模板)+(树状数组)
题意:有一个数组,有两种操作。1: Q a b 求[a,b]的和 2:C a b c 给[a,b] 的所有元素都加上c。题目:You haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given nu...原创 2019-08-02 20:16:14 · 254 阅读 · 0 评论 -
Minimum Inversion Number HDU - 1394(求一个数字环的逆序对+多种解法)
题意:给出n个数(0~n-1,每个数仅出现一次),问它长为n的循环序列中逆序对最少的数量。题目:The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.For a given seque...原创 2020-02-29 22:05:49 · 385 阅读 · 0 评论