LuoguBZOJ分析有向图上的$\texttt{Matrix_Tree}$定理的板子。这题以$1$为根,所以只能删去第一行和第一列。代码//It is made by M_sea
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#in...
LuoguBZOJ分析求出来的$n-1$条边要满足两个限制:构成一颗生成树恰好$n-1$种颜色考虑容斥,用至多$n-1$种颜色的,减去至多$n-2$种的,加上至多$n-3$种的,......至于生成树个数怎么求,用$\texttt{Matrix_Tree}$定理就行了。然后就可以直接枚举子集容斥去算了。代码//It is made by M_sea
#include <algorith...