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

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

I was solving this problem Kingdom Division but i don't know where am i going wrong(just the logic), please forgive me if am doing some very stupid mistake here, I have just started to learn DP, below i am presenting my approach :--

my code with explanation

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

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

Have you tried the following:

  • Write a very naive and simple solution to the problem (maybe exponential complexity) (if you can, you may also just copy someone else's solution)

  • Write a program to generate thousands of small (!) test cases

  • Using those two, find a test case where your program gives the wrong answer

  • Use print statements or a debugger to see where exactly your program does the wrong thing.

98% of WAs and REs can be resolved this way. People here don't have time to delve into every code posted here, it's much harder to debug somebody else's code and being able to debug your own code is a valuable skill. It is also a very routine process that can be learned much faster than problem solving and algorithms.