BFS code not working properly

Правка en1, от ss_96, 2017-09-22 22:02:20

I was trying to solve the following problem:

You are given a grid of size N×N that has the following specifications:

Each cell in the grid contains either a policeman or a thief.

A policeman can only catch a thief if both of them are in the same row.

Each policeman can only catch one thief.

A policeman cannot catch a thief who is more than K units away from the policeman.

Write a program to find the maximum number of thieves that can be caught in the grid.

My solution:solution

PS:This was a question of question and I have completed the test,couldn't qualify ,that's why asking for guidance here.Please suggest what corner cases are missing with the solution code.


Теги c++, graph, bfs


  Rev. Язык Кто Когда Δ Комментарий
en1 Английский ss_96 2017-09-22 22:02:20 953 Initial revision (published)