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 :--
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | Um_nik | 162 |
3 | maomao90 | 161 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 152 |
9 | luogu_official | 152 |
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 :--
Name |
---|
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.
yes , it makes a lot of sense but i was just talking about the logic , whether am i approaching in right direction or not ,sry, i didn't clearly mentioned there about this. OK from next time i will not repeat this compelling mistake again!! and thanks for ur humbleness, u r a nice person ...
Wait, I'm not sure I understand what you want here. Do you just want like a hint or something? Or do you want to know what's wrong with your code? If you have a test case that breaks your code it should be quite easy to understand where the mistake in your logic is.
Basically i was trying to do it using 2d states but in editorial they have used 3d states, so just wanted to know why my logic will not work, take this code as pseudo-code , am not asking someone to find bugs here, lol.
Seriously, try the stress testing if you haven't already, it always helps me in such situations.