线段树
反向爆零直至AK
从零开始的编程生活,枯燥却紧张
展开
-
线段树之区间求和(士兵杀敌(一))
刚学了线段树,以士兵杀敌(一)为例,简单介绍一下。 士兵杀敌(一):http://115.159.40.116/problem_show.php?pid=4720简单介绍线段树 线段树是一种二叉搜索树,与区间树相似,它将一个区间划分成一些单元区间,每个单元区间对应线段树中的一个叶结点。 使用线段树可以快速的查找某一个节点在若干条线段中出现的次数,时间复杂度为O(logN)。而未优化的空间复杂度原创 2017-07-11 14:26:38 · 219 阅读 · 0 评论 -
求最大值(经典线段树)
题目链接:https://www.nowcoder.com/acm/contest/30/E时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 给出一个序列,你的任务是求每次操作之后序列中 (a[j]-a[i])/(j-i)【1<=i < j<=n】 的最大值。 操作次数有Q次,每次操作需原创 2017-12-11 20:17:53 · 1654 阅读 · 0 评论 -
Can you answer these queries?(线段树,区间更新,更新到点)
题目 链接:传送门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 valu原创 2017-08-05 16:59:30 · 211 阅读 · 0 评论 -
楼房重建 (线段树)
题目链接:传送门 2957: 楼房重建Time Limit: 10 Sec Memory Limit: 256 MB Submit: 2289 Solved: 1081 [Submit][Status][Discuss] Description 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋原创 2017-08-12 18:44:40 · 551 阅读 · 0 评论 -
Count the Colors (线段树,区间更新)
Count the Colors 链接:传送门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原创 2017-08-04 21:51:58 · 169 阅读 · 0 评论 -
A Simple Problem with Integers (线段树,区间求和+区间更新)
A Simple Problem with Integers 链接:传送门You have NN integers, A1,A2,⋯,ANA1,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 giv原创 2017-08-04 21:22:14 · 230 阅读 · 0 评论 -
B - I Hate It (线段树,点的更新+区间最大值)
B - I Hate It 链接:传送门很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0原创 2017-08-04 21:01:27 · 174 阅读 · 0 评论 -
hdu 3265 Posters (线段树,离散化+扫描线)
题目链接:传送门PostersTime Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6379 Accepted Submission(s): 1537Problem DescriptionTed has a new house with原创 2017-08-11 17:29:26 · 237 阅读 · 0 评论 -
hdu 1542 Atlantis (线段树,离散化+扫描线)
Atlantis 题目链接:传送门AtlantisTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13741 Accepted Submission(s): 5704Problem DescriptionThere are se原创 2017-08-09 17:35:16 · 305 阅读 · 0 评论 -
hdu 1255 覆盖的面积 (线段树,离散化+扫描线)
题目链接:传送门覆盖的面积Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6058 Accepted Submission(s): 3051Problem Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次原创 2017-08-11 10:31:58 · 230 阅读 · 0 评论 -
POJ 2528 Mayor's posters (线段树+离散化)
Mayor’s posters 题目链接:传送门DescriptionThe 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原创 2017-08-09 08:49:41 · 277 阅读 · 0 评论 -
Cinema in Akiba(线段树求解位置)
题目链接:Cinema in AkibaCinema in Akiba Time Limit: 3 Seconds Memory Limit: 65536 KB Cinema in Akiba (CIA) is a small but very popular cinema in Akihabara. Every night the cinema is full of peopl...原创 2018-05-09 08:26:04 · 242 阅读 · 0 评论