【树链剖分】
文章平均质量分 76
riba2534
没有谁生来就是神牛,而千里之行,始于足下!
展开
-
LightOJ 1348 Aladdin and the Return Journey(树链剖分)
描述 Finally the Great Magical Lamp was in Aladdin’s hand. Now he wanted to return home. But he didn’t want to take any help from the Genie because he thought that it might be another adventur...原创 2018-07-16 16:18:14 · 242 阅读 · 0 评论 -
SPOJ COT - Count on a tree(树链剖分+LCA+主席树,树上第k大)
描述 You are given a tree with N nodes. The tree nodes are numbered from 1 to N. Each node has an integer weight. We will ask you to perform the following operation: u v k : ask for the...原创 2018-07-21 18:12:24 · 615 阅读 · 0 评论 -
洛谷 P3379 【模板】最近公共祖先(LCA)(树链剖分写法)
题目链接: P3379 【模板】最近公共祖先(LCA)今天突然想到,树剖可以写LCA,就实现了一下,可以过,在这里存一下代码#include <cstdio>#include <cstring>#include <cctype>#include <stdlib.h>#include <string>#includ...原创 2018-07-21 11:33:25 · 325 阅读 · 0 评论 -
POJ3237 Tree(树链剖分,区间变相反数)
Description You are given a tree with N nodes. The tree’s nodes are numbered 1 through N and its edges are numbered 1 through N − 1. Each edge is associated with a weight. Then you are to ex...原创 2018-07-14 18:05:37 · 305 阅读 · 0 评论 -
SPOJ QTREE - Query on a tree(树链剖分,以边建树)
描述 You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3…N-1. We will ask you to perfrom some instructions of the following form: CHANG...原创 2018-07-14 15:15:34 · 451 阅读 · 0 评论 -
BZOJ4196 [Noi2015]软件包管理器(树链剖分,区间更新)
Description Linux用户和OSX用户一定对软件包管理器不会陌生。通过软件包管理器,你可以通过一行命令安装某一个软件包,然后软件包管理器会帮助你从软件源下载软件包,同时自动解决所有的依赖(即下载安装这个软件包的安装所依赖的其它软件包),完成所有的配置。Debian/Ubuntu使用的apt-get,Fedora/CentOS使用的yum,以及OSX下可用的homebrew都是优...原创 2018-07-13 16:23:35 · 194 阅读 · 0 评论 -
BZOJ4034 [HAOI2015]树上操作(树链剖分,更新区间)
Description 有一棵点数为 N 的树,以点 1 为根,且树点有边权。然后有 M 个 操作,分为三种: 操作 1 :把某个节点 x 的点权增加 a 。 操作 2 :把某个节点 x 为根的子树中所有点的点权都增加 a 。 操作 3 :询问某个节点 x 到根的路径中所有点的点权和。Input 第一行包含两个整数 N, M 。表示点数和操作数。...原创 2018-07-13 11:04:45 · 351 阅读 · 0 评论 -
BZOJ1036 [ZJOI2008]树的统计Count(树链剖分,单点更新)
Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w。我们将以下面的形式来要求你对这棵树完成 一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u v: 询问从点u到点v的路径上的节点的最大权值 I II. QSUM u v: 询问从点u到点v的路径上的节点的权值和 注意:从点u到点v的路径上的节点包括u和v...原创 2018-07-13 09:28:20 · 215 阅读 · 0 评论 -
洛谷 P3384 树链剖分(详解)
题目描述 如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作: 操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z 操作2: 格式: 2 x y 表示求树从x到y结点最短路径上所有节点的值之和 操作3: 格式: 3 x z 表示将以x为根节点的子树内所有节点值都加上z 操作4: 格...原创 2018-07-12 16:55:18 · 3944 阅读 · 0 评论 -
树链剖分详解
写在前面首先,在学树链剖分之前最好先把 LCA、树形DP、DFS序 这三个知识点学了 emm还有必备的 链式前向星、线段树 也要先学了。如果这三个知识点没掌握好的话,树链剖分难以理解也是当然的。树链剖分树链剖分 就是对一棵树分成几条链,把树形变为线性,减少处理难度 需要处理的问题:将树从x到y结点最短路径上所有节点的值都加上z求树从x到y结点最短路径上所有节点的...转载 2018-07-12 16:23:16 · 321 阅读 · 0 评论 -
HDU5029 Relief grain(树链剖分+离线标记,好题)
Problem Description The soil is cracking up because of the drought and the rabbit kingdom is facing a serious famine. The RRC(Rabbit Red Cross) organizes the distribution of relief grain in ...原创 2018-07-17 18:39:20 · 257 阅读 · 0 评论 -
UVA12655 Trucks(MST+树链剖分)
描述 The Subtle Balloons Company (SBC) is the main balloon provider for programming contests; it has huge factories and warehouses, as well as an extensive truck fleet to ensure the contestant...原创 2018-07-17 10:59:01 · 262 阅读 · 0 评论 -
HDU3966 Aragorn's Story(树链剖分)
Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn k...原创 2018-07-17 09:14:57 · 239 阅读 · 0 评论 -
FZU2082 过路费(树链剖分,边建树)
Problem Description 有n座城市,由n-1条路相连通,使得任意两座城市之间可达。每条路有过路费,要交过路费才能通过。每条路的过路费经常会更新,现问你,当前情况下,从城市a到城市b最少要花多少过路费。Input 有多组样例,每组样例第一行输入两个正整数n,m(2 <= n<=50000,1<=m <= 50000),接下来n-1行,每行...原创 2018-07-16 20:59:56 · 270 阅读 · 0 评论 -
E.Jiu Yuan Wants to Eat(ACM-ICPC 2018 焦作赛区网络预赛,树链剖分)
描述You ye Jiu yuan is the daughter of the Great GOD Emancipator. And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country...原创 2018-09-19 21:04:33 · 381 阅读 · 0 评论