Блог пользователя HDCoderKiller

Автор HDCoderKiller, история, 2 года назад, По-английски

Problem Statement You are given a tree with one node painted as black and rest all are colored as white.You can paint any white node as black if its parent is colored as black. Determine the count of the unique coloring of the tree. Note: the count should be returned mod(10^9+1)

Example input : N=3,blackNode=1,edges=[[1,2],[1,3]] output : 4

input : N=6,blackNode=1,edges=[[1,2],[2,3],[2,4],[4,5],[4,6]] output : 11

NOTE: I WILL POST ANOTHER TWO QUESTIONS AROUND 1 PM, SOLVER WILL GET REWARD!!

  • Проголосовать: нравится
  • -38
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

isnt it just dp and $$$f[u] = \sum_{v \in \rm{Son}} (f[v]+1)$$$ for $$$f[u]$$$ to be node $$$u$$$ painted black