ID Origin Title 228 / 440 Problem A HDU 1166 敌兵布阵   207 / 438 Problem B HDU 1754 I Hate It   181 / 727 Problem C POJ 3468 A Simple Problem with Integers   105 / 410 Problem D POJ 2528 Mayor's posters   138 / 230 Problem E HDU 1698 Just a Hook…
https://vjudge.net/contest/66989#problem/A 单点修改,区间查询 方法一:线段树 http://www.cnblogs.com/kuangbin/archive/2011/08/15/2139834.html #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<cmath> #include<a…
1. HDU1166 裸线段树点修改 #include <iostream> #include <string.h> #include <cstdio> #include <queue> #include <map> #include <vector> #include <string> #include <cstring> #include <algorithm> #include <mat…
题目描述 给定n个整数构成的序列,将对于指定的闭区间查询其区间内的第k小值. 输入输出格式 输入格式 第一行包含两个正整数n,m,分别表示序列的长度和查询的个数. 第二行包含n个整数,表示这个序列各项的数字. 接下来m行每行包含三个整数l,r,k, 表示查询区间[l,r]内的第k小值. 输出格式 输出包含m行,每行一个整数,依次表示每一次查询的结果 输入输出样例 输入样例 5 5 5957 6405 15770 26287 26465 2 2 1 3 4 1 4 5 1 1 2 2 4 4 1…
本题使用线段树自然能够,由于区间的问题. 这里比較难想的就是: 1 最后更新须要查询全部叶子节点的值,故此须要使用O(nlgn)时间效率更新全部点. 2 截取区间不能有半点差错.否则答案错误. 这两点卡了我下.看来我的线段树还是不够熟,须要多多练习. 线段树是二分法的高级应用,可是却不是简单应用,要锻炼好并应用好线段树思维还是比二分法难非常多的. static const int SIZE = 100005; static const int TREESIZE = SIZE<<2; int a…
http://poj.org/problem?id=1389 题面描述在二维xy平面中有N,1 <= N <= 1,000个矩形.矩形的四边是水平或垂直线段.矩形由左下角和右上角的点定义.每个角点都是一对两个非负整数,范围从0到50,000,表示其x和y坐标. 求出所有矩形的面积(重叠部分只算一次) 示例:考虑以下三个矩形: 矩形1:<(0,0)(4,4)>, 矩形2:<(1,1)(5,2)>, 矩形3:<(1,1)(2,5)>. 所有由这些矩形构造的简单多…
一.区间查询,无单点更新 hdu2795 Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 25062    Accepted Submission(s): 10274 Problem Description At the entrance to the university, there is a huge rec…
本题就是要往墙上贴海报,问最后有多少可见的海报. 事实上本题的难点并非线段树,而是离散化. 由于数据非常大,直接按原始数据计算那么就会爆内存和时间的. 故此须要把数据离散化. 比方有海报1 6   7 9   20 100  5 1000的原始数据.直接计算须要1-1000的内存,离散化之后仅仅须要8内存,由于仅仅有4组数据8个数. 本题更进一步高级一点的离散化就是须要把不相邻的两个数据插入一个数值.表示有空白的地方,不是全部海报都覆盖到的. 比方上面的数据要离散为:1 2  5 6  7 8…
地址 http://poj.org/problem?id=3468 线段树模板 要背下此模板 线段树 #include <iostream> #include <vector> #include <math.h> #include <algorithm> using namespace std; /* Sample Input 10 5 1 2 3 4 5 6 7 8 9 10 Q 4 4 Q 1 10 Q 2 4 C 3 6 3 Q 2 4 Sample…
https://vjudge.net/contest/66989#problem/C #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> #define lson (i<<1) #define rson (i<<1|1) typedef long lo…