树启发式合并
树启发式合并
王江奎
这个作者很懒,什么都没留下…
展开
-
Tree Intersection-树启发式合并
Bobo has a tree with n vertices numbered by 1,2,…,n and (n-1) edges. The i-th vertex has color c i, and the i-th edge connects vertices a i and b i. Let C(x,y) denotes the set of colors in subtree ro...原创 2020-01-11 17:59:41 · 176 阅读 · 0 评论 -
树启发式合并入门
所谓启发式合并,就是一种符合直觉的合并方法:将小的子树合并在大的子树上。 这些问题一般是相似的问题背景:都是树上的计数问题,都不能直接从上往下进行暴力,都需要从下往上计数时对子树信息进行运算从而得到父亲节点的信息。这个运算一般是启发式合并。 一般使用map保存子树的一些信息,例如树的颜色,树孩子的多少等等。选择map的原因我认为有以下几点: map可以非常方便地保存离散的信息,而且可以对这些离散...原创 2020-01-11 17:51:57 · 165 阅读 · 0 评论