2020-03-30から1日間の記事一覧

Codeforces darkshadows's blog 「DP on Trees Tutorial」Problem 3

Codeforces darkshadows's blog 「DP on Trees Tutorial」Problem 2の続編です。 codeforces.com 問題3. 「頂点数nの木が与えられたとき、頂点がk個以下のサブツリーの数はいくつあるか?」 ここでいう「サブツリー(sub tree)」は、今まで使っていた「部分…

Codeforces darkshadows's blog 「DP on Trees Tutorial」Problem 2

codeforces.comCodeforces darkshadows's blog 「DP on Trees Tutorial」Problem 1の続編です。 問題2. 「頂点数がnの木の直径を求めよ(木の直径とは、木の異なる2頂点間の距離の最大値です)。」 木全体の根を頂点1とし、ある頂点xに着目してみましょう…