
线段树
文章平均质量分 92
ecjtu-虹林
这个作者很懒,什么都没留下…
展开
-
HDU - 1542 Atlantis 和 POJ - 1177 Picture
HDU - 1542 Atlantis 和 POJ - 1177 Picture HDU1542 There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe different r原创 2021-04-24 21:41:16 · 158 阅读 · 0 评论 -
线段树
线段树 线段树是一棵二叉搜索树,它储存的是一个区间的信息。下面是一个简单的线段树。 由上图可得, 1、每个节点的左孩子区间范围为[l,mid],右孩子为[mid+1,r] (mid=(l+r)/2) 2、对于结点k,左孩子结点为2k,右孩子为2k+1,这符合完全二叉树的性质 废话少说,下面是线段树的基本操作: struct node { int l,r,w;//l,r分别表示区间左右端点,w表示区间和 }tree[400000]; 先用结构体构建一个树,其实也不是一定要建一个结构体,你也可原创 2021-03-14 15:23:52 · 131 阅读 · 0 评论