kuangbin带我飞QAQ 线段树】的更多相关文章

1. HDU1166 裸线段树点修改 #include <iostream> #include <string.h> #include <cstdio> #include <queue> #include <map> #include <vector> #include <string> #include <cstring> #include <algorithm> #include <mat…
1. POJ 2236 给出N个点,一开始图是空白的,两个操作,一个是增加一个点(给出坐标),一个是查询两个点间是否相通,当两点间的距离小于D或者两点通过其他点间接相连时说这两个点相通.并查集维护,每次增加一个点加入到vector中并于之前的点比较,距离小于D则合并到一个集合即可. #include <iostream> #include <string.h> #include <cstdio> #include <vector> #include <…
1. hust 1017 DLX精确覆盖 模板题 勉强写了注释,但还是一脸懵逼,感觉插入方式明显有问题但又不知道哪里不对而且好像能得出正确结果真是奇了怪了 #include <iostream> #include <string.h> #include <cstdio> #include <queue> #include <map> #include <vector> #include <string> #include…
1. poj 1502 Mathches Game 裸最短路 #include <iostream> #include <string.h> #include <cstdio> #include <queue> #include <vector> #include <string> #include <cstring> #include <algorithm> #include <math.h> #…
        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-n中的最大值,那么我们如果使用暴力来查找,那么我们每次查找的复杂度就是O(n) 但是如果我们把一个个区间变成树上的一个个点,并且我们严格保证树的深度,那么我们每次查找的复杂度就是O(logn) 这样就能让查询变得更快. 我们先简单讲一下线段树的存储(图中的标号就是线段树数组标号) 这就是线段…
HDU 1166 敌兵布阵 单调更新区间查询和 #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #inc…
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 the two at the ends, every village was directly con…
For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a contiguous range of cows fr…