线段树/树状数组
刀锋灬意志
嘤嘤嗡嗡
展开
-
HDU1754-I Hate It(线段树 单点更新,区间查询最大)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含...原创 2019-04-05 19:14:13 · 152 阅读 · 0 评论 -
2019南京网络赛-A-The beautiful values of the palace(树状数组 二维偏序)
题目链接 题意 一个螺旋的矩阵,大小为n*n,n一定为奇数。有m个位置有值,值就是螺旋矩阵上的值,其他没有列举的位置都为0. 给了x1,y1,x2,y2,求矩形区域(x1,y1)(x2,y2)内所有数的综合。 思路 求矩形区域,可以转化为求四个前缀和。但是1e6限制了不能用二维树状数组,所以求前缀和的时候按照Y从小到大的顺序,将二维转化为一维。 会爆int,用ll存 参考 #inc...原创 2019-09-01 21:54:15 · 287 阅读 · 0 评论 -
HDU6681-Rikka with Cake(转化为线段树模型)
题目链接 Problem Description Rikka's birthday is on June 12th. The story of this problem happens on that day. Today is Rikka's birthday. Yuta prepares a big cake for her: the shape of this cake is a rec...原创 2019-08-30 20:26:17 · 184 阅读 · 0 评论 -
2019CCPC网络赛-HDU6703-array (线段树 权值线段树?)
题目链接 题意 样例第一个 ,序列 4 3 1 2 5 ,有两个操作: 1 5 :1操作,给第五个位置的数加10,000,000; 2 1 1(op,r ,op): 2操作,找一个大于等于k的数,且和区间 [ 1,r ]中的数不相等,求这个数的最小值。 思路 设数组 a[ n ] 记录当前的序列,设数组 b [ n ] 反向记录数组a,即记录每个数出现的位置。 如果 a [ ] 为 ...原创 2019-08-27 21:54:23 · 251 阅读 · 4 评论 -
POJ3321-Apple Tree(DFS序+线段树)
题目链接 There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree. The tree...原创 2019-08-11 08:24:45 · 163 阅读 · 0 评论 -
POJ2299-Ultra-QuickSort(树状数组 离散化)
题目链接 Description In 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 s...原创 2019-08-12 15:01:57 · 121 阅读 · 0 评论 -
POJ2155-Matrix(二维树状数组)
题目链接 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can chang...原创 2019-08-12 15:26:06 · 107 阅读 · 0 评论 -
POJ2528-Mayor's posters(线段树+离散化 or 分治+dfs)
题目链接 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 co...原创 2019-08-07 19:54:30 · 177 阅读 · 0 评论 -
POJ3468-A Simple Problem with Integers(线段树 区间更新 加和)
题目链接 Description 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...原创 2019-08-06 18:52:54 · 95 阅读 · 0 评论 -
HDU1698-Just a Hook(线段树 区间更新 lazy标记)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1698 Problem Description 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 seve...原创 2019-04-09 15:24:37 · 150 阅读 · 0 评论 -
Codeforces Round #373 div1 C-Sasha and Array(线段树维护矩阵 矩阵快速幂)
题目链接 题意 给一个数组,值表示第x个斐波那契数。有两个操作: 区间求和:对区间的值求相应的斐波那契数,然后求和 区间修改:对区间范围的数都加上y(代表的斐波那契数的下标往后加y个) 假设f[0] = 0,f[1] = 1 ,f[2] = 2 。。。。然后求第k个斐波那契数就相当于把2*2的矩阵[ [1 1] [1 0] ]自乘k-1次,求m[0][0]就是了。 线段...原创 2019-09-22 23:45:19 · 156 阅读 · 0 评论