题目 用$n$个点组成二叉树,问高度$\geq h$的有多少个。 分析 首先前缀和相减就能得到答案,做dp 设$dp[n][h]$表示节点数为$n$,高度不超过$h$的树的个数 那么$dp[n][h]=\sum_{i=0}^{n 1}dp[i][h 1] dp[n i 1][h 1]$ 最后输出$d ...
分类:
其他好文 时间:
2020-02-04 15:29:33
阅读次数:
56
"Link" 看到全是度数相关的计数就可以考虑Prufer序列。 一个点的度数就是其在Prufer序列中的出现次数$+1$,而一个Prufer序列的贡献就是其所有元素出现次数$+1$的乘积,我们可以把乘积拆开dp。 设$f_{x,i}$表示考虑前$x$个点,Prufer序列长度为$i$的答案之和。 ...
分类:
其他好文 时间:
2020-02-03 22:54:24
阅读次数:
135
Binary Search Trees: BST树里首先讲了插入删除查找等操作,比较常规。查找:最差O(n),最好O(logn),平均O(logn);插入:成功的插入平均O(logn),最差也是O(n);删除里有三种情况,对于一次成功的删除,待删除的结点v的子结点个数只可能是0、1、2,如果是0的话 ...
分类:
其他好文 时间:
2020-02-01 16:03:31
阅读次数:
70
一:HDU1754 #include<iostream> #include<algorithm> using namespace std; const int maxn=2e+5; int n,m,a[maxn]; struct tree{ int l,r,v; }trees[maxn<<2]; v ...
分类:
其他好文 时间:
2020-01-29 20:10:30
阅读次数:
84
"Link" 众所周知Kirchhoff定理中的边权可以是多项式。 直接NTT的复杂度是$O(n^4\log n)$。 带$n$个值进去算然后~~快速插值~~Lagrange插值或者Gauss消元是$O(n^4)$的。 ...
分类:
其他好文 时间:
2020-01-28 22:57:31
阅读次数:
73
给定两棵树 A, B。现你需要构造一组值 (X1, X2, ..., XN)(两棵树编号相同的点对应权值相同),使得两棵树内任意子树的权值和的绝对值为 1。
无解输出 IMPOSSIBLE。 ...
分类:
其他好文 时间:
2020-01-26 19:09:34
阅读次数:
102
1. how to construct a KNN graph? 常见的方法一般有三类: i. space-partitioning trees; ii. locality sensitive hashing; iii. neighbour exploring techniques. Referen ...
分类:
其他好文 时间:
2020-01-22 19:59:12
阅读次数:
132
There are nn Christmas trees on an infinite number line. The ii -th tree grows at the position xixi . All xixi are guaranteed to be distinct. Each int ...
分类:
其他好文 时间:
2020-01-21 13:20:26
阅读次数:
96
标签:生成函数,多项式exp 有 $n$ 个点,每个点有一个度数 $v[i]$,代表如果选择这个点就必须满足这个点与 $v[i]$ 条边相连. 求:有多少种选法,使得所选集合中的点能构成一棵树. 如果 $m$ 个点能生成一颗树,那么一定满足 $\sum v_{i}=2\times (m-1)$ 这是 ...
分类:
其他好文 时间:
2020-01-18 16:44:33
阅读次数:
54
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: Input: 3 Output: [ [1,null,3,2], ...
分类:
其他好文 时间:
2020-01-08 12:43:14
阅读次数:
72