Query on The Trees Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 4091    Accepted Submission(s): 1774 Problem Description We have met so many problems on the tree, so today we will have a que…
人生的第一道动态树,为了弄懂它的大致原理,需要具备一些前置技能,如Splay树,树链剖分的一些概念.在这里写下一些看各种论文时候的心得,下面的代码是拷贝的CLJ的模板,别人写的模板比较可靠也方便自己学习理解,然后一些概念的则是学习了一些论文,下面的内容可以看作对别人模板的理解心得,以及对论文的收获体会. LCT支持的主要是一种树路径上的操作,譬如说对u和v之间的路径上询问点权的和,询问点权的最大值,对所有点权加一个数,置为一个树等等.它和树链剖分不同的是,它支持将这个树上的边切掉,也支持将两个树…
Problem Description We have met so many problems on the tree, so today we will have a query problem on a set of trees. There are N nodes, each node will have a unique weight Wi. We will have four kinds of operations on it and you should solve them ef…
题意 给定一棵 \(n\) 个节点的树,每个点有点权.完成 \(m\) 个操作,操作四两种,连接 \((x,y)\) :提 \(x\) 为根,并断 \(y\) 与它的父节点:增加路径 \((x,y)\) 的节点一个 \(w\) 的点权:求路径 \((x,y)\) 的最大点权. 思路 基本概念介绍 \(\text{Link-Cut-Tree}\) 是一棵支持修改的树,以 \(\text{Splay}\) 为基础,均摊复杂度 \(O(n\log n)\) 的在线数据结构,支持的基础操作如下: 连边…
Query on The Trees Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 6447    Accepted Submission(s): 2547 Problem Description We have met so many problems on the tree, so today we will have a que…
375. Query on a tree Problem code: QTREE 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: CHANGE i ti : change the cost of…
LCT: 分割.合并子树,路径上全部点的点权添加一个值,查询路径上点权的最大值 Query on The Trees Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 2582    Accepted Submission(s): 1208 Problem Description We have met so many problems…
洛谷:P3690 [模板]Link Cut Tree (动态树) /*诸多细节,不注意就会调死去! 见注释.*/ #include<cstdio> #include<iostream> #include<algorithm> using namespace std; ; int n,m; ]; ]!=x && ch[fa[x]][]!=x; } ]]^xr[ch[x][]]^val[x]; } ]==x ;} ]]^=; rev[ch[x][]]^=;…
题面 题解 因为每个点都只能向后跳到一个唯一的点,但可能不止一个点能跳到后面的某个相同的点, 所以我们把它抽象成一个森林.(思考:为什么是森林而不是树?) 子节点可以跳到父节点,根节点再跳就跳飞了. 由于我们发现有一些父子关系要变,所以不能用树链剖分等静态的数据结构,可以用LCT(Link-Cut-Tree 联-切-树,即动态树,支持动态修改父子关系). 但是当我们询问答案的时候,我们发现wa了,那是因为我们询问的是x点到根的路径上的点数,但是各种LCT操作已经把原先的根不知换到那里去了,所以整…
题目:http://acm.fzu.edu.cn/problem.php?pid=2082 Problem 2082 过路费 Accept: 528    Submit: 1654Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description 有n座城市,由n-1条路相连通,使得任意两座城市之间可达.每条路有过路费,要交过路费才能通过.每条路的过路费经常会更新,现问你,当前情况下,从城市a到城市b最少要花多少过路费.  …