I followed the official editorial for this and I seem to be getting WA on a handful of cases. I am using an optimzed version of the algorithm in the editorial. The logic is that for every zombie, we can construct 4 squares of side 'r' with the point at each of the square corners. So select any two points and for all 16 sets of square for these two, find the points in the union of these two squares and output the max. The exact code is given here
Even i used the same approach don't know why i got WA
The issue is that we will miss cases like Bassel suggested. Hence you need two points to decide a square with one point on top edge and one on the left edge.
infomaniac we can define the square with one lower left corner and side length ?
Yes you can technically define a square like this but you cannot guarantee that an optimal square has a point on a corner, that's the issue.
So how can i get that all possible squares can you put some light on it ?
As already stated, consider a pair of points for a square, with one on the top edge and one on the left edge. Refer to the official editorial for details.
======
|___o__|
|o____o|
|__o___|
======
======
|___o__|
|o____o|
|__o___|
======
Your algorithm will fail a test case like this one based on your description
It will print 6 instead of 8
Thanks. Now I see the issue.