- 博客(14)
- 资源 (2)
- 收藏
- 关注
原创 浅谈线段树+模板
推荐两篇线段树博文: 线段树之一; 线段树之二;小结: 线段树是一种二叉树,也可以说成是区间树,操作有:建树build,更新updata(单点+区间),查询query(单点+区间)。单点操作时把区间不断二分,用root指向数组下标;区间更新操作时,标记lazy,先对子树的根节点做更新,当用到的这个子树的时候,再把标记下推,同时递归时向上统计,更新区间;区间查询时,会有遍历的一个操作遇到l...
2018-01-31 15:40:23 422
原创 hdu 4578 Transformation【线段树区间&思维】
Problem Description 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
2018-01-31 14:41:50 294
原创 Codeforces Round #459 (Div. 2) C.The Monster【贪心&括号匹配】
A. The Monster time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output As Will is stuck in the Upside Down, he can still communicate wit
2018-01-30 17:16:06 221
原创 C++ 类和对象
小谈C++学习之路类本身又是一种用户自定义的类型(暂且类似于结构体类型) 对象的空间分配 = 所有成员变量内存之和 类似于结构变量,对象之间可以”=”进行赋值,但不能用”> *使用类的成员变量和成员函数 用法一: 对象名.成员名 这里的成员名,可以是成员变量,也可以是成员函数 student R1, R2; R1.w = R1.h = 4; R2.init(4,4);
2018-01-29 22:12:43 129
原创 2018年全国多校算法寒假训练营练习比赛(第二场)
A 吐泡泡 链接:https://www.nowcoder.com/acm/contest/74/A 来源:牛客网 题目描述 小鱼儿吐泡泡,嘟嘟嘟冒出来。小鱼儿会吐出两种泡泡:大泡泡”O”,小泡泡”o”。 两个相邻的小泡泡会融成一个大泡泡,两个相邻的大泡泡会爆掉。 (是的你没看错,小气泡和大气泡不会产生任何变化的,原因我也不知道。) 例如:ooOO...
2018-01-29 22:01:51 325
原创 牛客练习赛 11
A 假的线段树 链接:https://www.nowcoder.com/acm/contest/59/A 来源:牛客网 题目描述 给你一个长为n的序列a,有m次操作 1.把区间[l,r]内所有x变成y 2.查询区间[l,r]内第k小值 输入描述: 第一行两个数n,m,第二行n个数表示序列a,后面m行 1 l r x y :把区间[l,r
2018-01-27 16:12:48 553
原创 HDU 1540【线段树区间合并】
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except t
2018-01-26 18:01:29 176
原创 HDU 4027【线段树技巧题】
A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of end
2018-01-24 21:20:49 498
原创 POJ 2528【线段树染色+离散化】
Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city cou...
2018-01-24 13:46:39 168
原创 ZOJ 1610【线段树区间染色】
Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different colors you can see at last.
2018-01-24 10:20:18 174
原创 HDU 1698【线段树区间修改】
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
2018-01-24 00:31:11 136
原创 POJ 3468 【线段树区间更新】
You 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 to ask for the su
2018-01-24 00:26:06 207
原创 与n互质的平方和【容斥&数学】
题目描述 小李子有n-1个朋友,分别编号为1..n-1,小李子的编号是n ,小李子的表面朋友的编号会与小李子编号互质 我们定义小李子老年生活的悲惨度是表面朋友的编号的平方和 输入 多组输入(小于等于10000组) 每组输入一个n( 输出 输出小李子的悲惨度 样例输入 2 3分析: 求1~n与n互质的数平方和。把n分解质因子,进行容
2018-01-06 14:37:44 1946 2
原创 HPU 1470: 中位数 【分治】
时间限制: 1 Sec 内存限制: 128 MB 题目描述 Ocean有两个升序序列A和B,现在他将A和B合并后得到新序列C,他想知道序列C的中位数。 输入 第一行输入一个整数T,代表有T组数据。每组数据第一行输入一个整数N,代表A、B序列元素个数。接下来一行依次输入N个整数,代表序列A的元素。接下来一行依次输入N个整数,代表序列B的元素。 注:1<=T<=5000,1
2018-01-01 18:19:57 259
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人