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

Автор kritipandey, история, 5 лет назад, По-английски

Appeared in Lowes test

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

It can be solved by a dynamic approach. In order to get an answer for vertex, we can calculate answers for all children and then multiply them.

$$$dp[v]$$$ — number of ways color black the subtree of $$$v$$$.

$$$dp[leaf] = 1$$$, for all leafs

$$$dp[v] = \prod (dp[child] + 1)$$$

You can calculate it by simple dfs. Answer will be in $$$dp[root]$$$

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

https://atcoder.jp/contests/dp/tasks/dp_v Harder version of the same problem.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +30 Проголосовать: не нравится

I added Walmart to my boycott list ;)

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

This was the same question which was asked earlier in the LOWE's exam also. I solved it using DFS.

DFS