![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
zy-yz
编程小白一只
展开
-
hdu 2795
题目链接 解析:这个是一个挺有意思的线段树,我们将第一行看作线段树最左端节点L,最后一行看作线段树最右节点R,宽度作为权值w,然后根据题目要求,每次先遍历左子树,若左子树装不下广告了,再遍历右子树。 代码如下: #include<iostream> #include<algorithm> #include<string> #include<c...原创 2018-11-02 16:24:28 · 192 阅读 · 0 评论 -
树链剖分
洛谷P2590 树链剖分模板题: #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=50005; int n,q; int w[maxn];//每个点的权值 int father[maxn];//每个点的父亲 int son[maxn]; //每个点的重儿子是谁 i...原创 2019-04-24 20:50:17 · 74 阅读 · 0 评论