Ive been struggling for 5 hours straight and I’m still not able to find the solution to and get an AC in the problem . You can get the question above . My approach is just like the editorial
let’s look on Nxi rectangle formed with the first i columns. What can we say about its last stripe? Either it’s black or white and his width is ranged from x to y. Let’s imagine the last stripe in your subrectangle is white. It means that previous stripe’s color has to be the different (black). Then, for each a x <= a <= y check the cost of oainting rectangle Nx(i-a) in stripes so it will end with the black stripe (dp[i-a])and add the cost of painting columns from i-a+1 to i in white (sum-of-whites(i-a+1,i)). Then we keep the best outcome.
Same thing with the case, where the last stripe in rectangle Nxi is white, but with reverse colouring.
I’m Not able to get the answer , somebody Please help .