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

Автор 901001, 15 лет назад, По-английски
Can someone help me how to solve this problem.I use greedy algorithm,every time I find the point which can destroy most rocks,but it wrong answer. I cannot find what data make the solution WA. Can someone tell me how to solve it?
thanks in advance!
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

15 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Greedy is incorrect. Solution is optimized search. There is O(2^n) search algorithm which fits in time limit.

15 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I thought of a 2^25 times 25 algo. Will it pass the limit ?

15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
111111
001000
000100
010010

Here are four "greediest" points at first move, I think, but two of them lead your algorithm to wrong way with three bombs instead of two.
15 лет назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

You can solve this problem using Hungarian algorithm.
http://en.wikipedia.org/wiki/KM_algorithm