数据结构——线段树
Alex_McAvoy
想要成为渔夫的猎手
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
I Hate It(HDU-1754)
Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N...原创 2019-02-16 14:27:02 · 344 阅读 · 0 评论 -
A Simple Problemwith Integers(POJ-3468)
Problem 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 ot...原创 2019-02-16 15:14:01 · 380 阅读 · 1 评论 -
Naive Operations(HDU-6315)
Problem Description In a galaxy far, far away, there are two integer sequence a and b of length n. b is a static permutation of 1 to n. Initially a is filled with zeroes. There are two kind of ope...原创 2019-02-16 18:47:51 · 398 阅读 · 0 评论 -
Can you answer these queries?(HDU-4027)
Problem Description 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...原创 2019-02-16 19:04:45 · 732 阅读 · 0 评论 -
Tunnel Warfare(HDU-1540)
Problem Description 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 l...原创 2019-02-16 19:47:18 · 458 阅读 · 0 评论 -
数据结构 —— 线段树
【概述】 线段树是一种二叉搜索树,其存储的是一个区间的信息,每个结点以结构体的形式去存储,每个结构体包含三个元素:区间左端点、区间有端点、该区间要维护的信息(视实际情况而定),其基本思想是分治的思想。 其特点是: 每个节点的左孩子区间范围为 [l,mid],右孩子为 [mid+1,r] 对于结点 k,左孩子结点为 2*k,右孩子为 2*k+1,符合完全二叉树的性质 线段树一般结构如图: ...原创 2019-02-14 16:18:30 · 1192 阅读 · 0 评论 -
肥猪
【题目描述】 小B来到了一个异世界,成为了肥猪之王。 在这个异世界,共有n种肥猪,编号分别为1,...,n。 小B希望集齐这n种肥猪。 召集肥猪有两种方式: 1. 花费a[i]的金币召唤一只编号为i的肥猪。 2. 花费x的金币使所有已召集的肥猪进化。 即编号为i的肥猪编号变成i+1,特殊的,编号为n的肥猪编号变成1。 请问小B最少要花多少金币才能集齐n种肥猪。 【输入描述】 第一...原创 2019-06-02 16:14:21 · 495 阅读 · 0 评论
分享