树链剖分
bootdubbo
这个作者很懒,什么都没留下…
展开
-
P3384 【模板】树链剖分
题目描述如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作:操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z操作2: 格式: 2 x y 表示求树从x到y结点最短路径上所有节点的值之和操作3: 格式: 3 x z 表示将以x为根节点的子树内所有节点值都加上z操作4: 格式: 4 x 表示求以x为根节点的子树内所有节点...原创 2019-08-03 20:13:42 · 105 阅读 · 0 评论 -
P3313 [SDOI2014]旅行【树链剖分好题】
题目描述S国有N个城市,编号从1到N。城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市。每个城市信仰不同的宗教,如飞天面条神教、隐形独角兽教、绝地教都是常见的信仰。为了方便,我们用不同的正整数代表各种宗教, S国的居民常常旅行。旅行时他们总会走最短路,并且为了避免麻烦,只在信仰和他们相同的城市留宿。当然旅程的终点也是信仰与他相同的城市。S国政府为每个城市标定了不同的旅行评级...原创 2019-09-10 22:20:06 · 267 阅读 · 0 评论 -
CodeForces - 343D Water Tree 【树链剖分+点权】【简单题】
Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water.The vertices of the tree are numbered from 1 ...原创 2019-08-05 09:22:59 · 105 阅读 · 0 评论 -
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 adventure for him. Al...原创 2019-08-05 10:14:02 · 164 阅读 · 0 评论 -
HDU - 6162 Ch’s gift 【树状数组+树链剖分】
Mr. Cui is working off-campus and he misses his girl friend very much. After a whole night tossing and turning, he decides to get to his girl friend’s city and of course, with well-chosen gifts. He kn...原创 2019-08-04 23:24:54 · 123 阅读 · 0 评论 -
SCU - 4549 Greed King 【树链剖分+边权】【区间更新】
Time Limit: 3000 MS Memory Limit: 131072 KDescriptionThere is a king who is very rich, but he is very stingy. In his kingdom, there are many cities.He built many highways to connect all the citi...原创 2019-08-04 21:08:36 · 105 阅读 · 0 评论 -
HDU - 5052 Yaoge’s maximum profit 【树链剖分】【区域赛金牌题】
Yaoge likes to eat chicken chops late at night. Yaoge has eaten too many chicken chops, so that Yaoge knows the pattern in the world of chicken chops. There are N cities in the world numbered from 1 t...原创 2019-08-04 17:42:19 · 227 阅读 · 0 评论 -
HYSBZ - 2243 染色【树链剖分+点权】【区间更新】
给定一棵有n个节点的无根树和m个操作,操作有2类:1、将节点a到节点b路径上所有点都染成颜色c;2、询问节点a到节点b路径上的颜色段数量(连续相同颜色被认为是同一段),如“112221”由3段组成:“11”、“222”和“1”。请你写一个程序依次完成这m个操作。Input第一行包含2个整数n和m,分别表示节点数和操作数;第二行包含n个正整数表示n个节点的初始颜色下面 行每行包含两个...原创 2019-08-04 15:51:02 · 135 阅读 · 0 评论 -
POJ - 3237 Tree【树链剖分+边权】【单边更新】【区间更新】
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 execute a series of inst...原创 2019-08-04 13:19:45 · 176 阅读 · 0 评论 -
HYSBZ - 1036 树的统计Count【树链剖分+点权】
一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w。我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u v: 询问从点u到点v的路径上的节点的最大权值 III. QSUM u v: 询问从点u到点v的路径上的节点的权值和 注意:从点u到点v的路径上的节点包括u和v本身Input 输入的第一行为一个整数n,...原创 2019-08-04 11:27:30 · 149 阅读 · 0 评论 -
POJ - 2763 Housewife Wind 【树链剖分+边权】
After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beautiful huts. There are some pairs of huts connected by bidirecti...原创 2019-08-04 10:18:21 · 218 阅读 · 1 评论 -
SPOJ - QTREE Query on a tree 【树链剖分+边权】
滑稽树上滑稽果,滑稽树下你和我,滑稽树前做游戏,滑稽树后做交易,滑稽多又多又到了众望所归的滑稽时刻今天我们将面对的,是恶名昭著的树上滑稽它有着n个滑稽果和编号为1~n-1的n-1条滑稽枝,每一条滑稽枝都连接着两个滑稽果并且有着自己的滑稽指数滑稽大军为了变得和它一样滑稽打倒它,将有以下两种形式的任务发布:(1)CHANGE i ti:滑稽指挥部需要你使用滑稽剑将编号为i的滑稽枝的滑稽指数变...原创 2019-08-04 00:03:08 · 171 阅读 · 0 评论 -
HDU - 3966 Aragorn's Story
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 knows, the enemy has N camps ou...原创 2019-08-03 21:09:02 · 130 阅读 · 0 评论 -
Assign the task HDU-3974【树链剖分+点权】
There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,that ...原创 2019-09-13 10:57:01 · 149 阅读 · 0 评论