i am unable to get the appraoch of this problem …
how can we apply dp here ??
what should be the thought process in making the solution??
the hint video is very confusing … and didn’t find it helpful
plz help on this
Unable to get the approach
https://online.codingblocks.com/app/player/37446/content/134582/6262/code-challenge here is the link to the problem
wait i have find the question on hackerblocks .
Let’s solve the problem for rectangle W×H (W≥H). Of course, we can cover all rectangle with itself for cost W. To get something smaller than W we have to leave at least one column uncovered — otherwise we pay at least sum of w over all rectangles which is at least W. This gives us an idea to use DP on rectangles to solve the problem: dp[x1][x2][y1][y2] is minimal cost to cover the rectangle [x1;x2)×[y1;y2). It is initialized by max(x2−x1,y2−y1), and we have to try not to cover every column/row. Of course, we have to check if it is all white from the beginning; to do that we will precalculate 2D prefix sums. Total complexity is O(5*n)…W and H are width and height of rectangle drawing canvas
For our question W = H = N because its a square
If you use eraser at each valid position complexity will be 0(n^4)
Your solution can have at max 0(n^3)
So pre-calculate number of black cells in each k size segment in rows and cols
When you place an erase somewhere, row will become white if black cells in row == black cells in k size segment from that position
Similarly you can solve for columns
So n^2 cells and n time at each cells gives 0(n^3)
not at all i have too seen this on hackerblocks discussion but unable to understand this…
you have seen the editorial as well and i have tried in theory way as well .
please tell what you havent understood in the editorial ?
i cannot understand what this editorial is trying to teach … i didn’t find its words easy
plz explain it in easy words maybe with some eg…
have you seen the code implementation of this question ?
i could explai it in easy words but first i am trying if you can get the logic yourself .
no i have not seen the code of this question and regarding thinking the logic part i have already spent alot of time thinkiing about the logic but it seems too confusing and the hint video has made it more confusing
wait let me see the hint video and if there is way i can explain in the simple way i can .
till then you can try any other question .
sir have you tried with some other approach ??
so plz tell someone else to help me on this otherwise my doubt will be unresolved its already two days
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.