Can someone tell me what am I doing wrong?
Editorial: https://codeforces.com/blog/entry/507 ( I followed the DP solution O((n*m)^2) )
00001 00000 10100 //ans is 12 ####1 ####0 10100
My approach: rectangle with coordinates (x1, y1, x2, y2) is correct if and only if rectangles (x1, y1, x2-1, y2) and (x1, y1, x2, y2-1) are correct, and board[x2][y2] = ‘0’.
ie: dp[x1][y1][x2][y2]=(dp[x1][y1][x2-1][y2] && dp[x1][y1][x2][y2-1] && (board[x2][y2]==0))
If it is correct then find it's perimeter (perimeter = 2*(x2-x1+y2-y1+2)) ie ans=max(ans,perimeter)
And dp[x1][y1][x2][y2]=1 for all i,j when board[x2][y2]==0. Because from point p1 to point p1, ie the same point always have a perimeter is the base case.