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

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

Hi. I was working on a DP problem (SPOJ MFISH) but I couldn't understand how the DP works. I've seen a few codes online but couldn't comprehend them either. Could someone explain it to me?

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

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

Consider the ships sorted by their anchor index. For every ship you can find a range of indexes where it can start. Just try every possible placement for each ship. The complexity is O(n) because you visit every index at most twice.

P.S.: Thanks to SPOJ, I just found out that there is a programming language called "chicken" :D