Condition
There is a field of size w * h (1 ≤ w, h ≤ 40000), on which N rooks are placed (0 ≤ N ≤ min (w, h)).
Each rook is given by the coordinate (x, y) (1≤ x ≤ w, 1 ≤ y ≤ h) on the field and beats all the cells that are on the same horizontal or vertical with it. Describe an effective algorithm for finding the largest rectangle in area, the cells of which are not beaten by any of the rooks.
My ideas: I thought, but I didn’t get something logically correct