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

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

Given a Graph $$$D$$$ of $$$N$$$ nodes, where each node $$$i$$$ has $$$C_i$$$ coins attached with it. You have to choose a subset of nodes such that no two adjacent nodes(i.e. nodes connected directly by an edge) are chosen and sum of coins attached with nodes in chosen subset is maximum.

For a tree this is a famous DP on Tree problem ( solution for Tree version here: https://codeforces.net/blog/entry/20935 -> Problem 1 ). Can we extend the DP on trees logic to solve it for a general graph. If not how can should I approach it?

Полный текст и комментарии »

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

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

You are given N intervals and Q ranges. For each range you have to count number of intervals lying completely inside the range.

How can we do this query per range in O(log n)?

Полный текст и комментарии »

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