
线段树
taozifish
http://www.daimayu.com/
展开
-
poj 3277 City Horizon
//数据很大,需要先离散化,然后线段树。#include#include#include#includeusing namespace std;const int MAXN=80005;struct node{ int left, right, mid, cover;};struct seg{int x[2], h;}p[40005];struct原创 2012-03-02 17:21:13 · 403 阅读 · 0 评论 -
poj 1151 Atlantis / hdu 1542 线段树扫描线 矩形面积并
#include#include#include#include#includeusing namespace std;const double EP=1e-8;const int maxn=205;int n, cas=1;double hash[maxn];struct nod{ double x; int c, id;}a[maxn];struct原创 2012-08-10 21:26:51 · 538 阅读 · 0 评论 -
poj 1177 / hdu 1828 Picture 矩形周长并
分x边和y边两次线段树扫描线,寻找cover值0->1的区域,长度*2即可。#include #include #include #include #include using namespace std;const int maxn=20005;const int TT=10000;int n;struct rect{ int x1, y1, x2, y2;}re原创 2012-08-11 14:06:12 · 552 阅读 · 0 评论 -
hdu 1394 Minimum Inversion Number 线段树求最小逆序数
可以不断将尾部移动到头部,求最小逆序数。 #include#include#include#include#includeusing namespace std;const int maxn=5005;int n, a[maxn];struct node{ int lef, rig, mid, cover;}seg[maxn*4];void make_tree原创 2012-08-11 22:04:38 · 483 阅读 · 0 评论 -
hdu 1255 覆盖的面积 矩形D层以上重叠面积
矩形面积并,求D层以上重叠的面积离散化后扫描线 4000ms低效率水过 #include#include#include#include#includeusing namespace std;const double EP=1e-8;const int maxn=2005;const int D=2;int n, cas=1;double hash[maxn];s原创 2012-08-10 22:45:56 · 1034 阅读 · 0 评论