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

Автор NaveeN_42, история, 8 месяцев назад, По-английски

Hello everyone. I participated in the sprinkler coding round and there was this question I was not able to solve completely. I did brute force and passed some test cases though.

The problem says, You are given a connected undirected graph. It has n nodes and m edges. Each node has some sweetness value that will be given to us.

The game is as follows:

Alice moves first and she may break a node. Each edge connected to this node will vanish. Bob will pick any connected component(containing all or some nodes) Alice will pick any remaining connected components if there are any The game ends in three steps. Both of them want to maximize their score by collecting maximum possible sweetness. They are not trying to minimize each other' score.

Determine the maximum score of Alice and Bob respectively. Assume both plays the game optimally.

Graph nodes index starts from 1. If no connected component left, alice gets 0

Input: number of test cases then n, m and then sweetness of each node and then the edges.

Example:

1

6 7

4 3 7 5 9 2

1 2

2 3

1 3

3 4

4 5

5 6

4 6

For this answer is 11 14

I tried to construct dfs tree by consisdering articulation points logic but couldn't understand.

How to solve this problem? Can someone please implement the CODE??

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

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