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

Автор Vital1ty, 10 лет назад, По-английски

Pls... help me out with this problem

http://www.spoj.com/problems/ANGELS/

It uses bipartite matching i guess. But am not able to build the graph .

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

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

Your guess is absolutely correct. Consider vertical and horizontal segments formed by adjacent symbols 'A' in every row and in every column. If we want to place a "fighter" in some square (i, j), we can't place any "fighter" in vertical and in horizontal segments that (i,j) belongs to.

So, we need to make a bipartite graph where vertices are segments and edges are squares (i,j) where we can place a "fighter".

Maximal matching in this graph is the answer for the problem.