# Wheat Field — Solution ## Comparing solutions The problem setter’s method enumerates two horizontal support lines determined by obstacles and field boundaries. Within their strip, it scans blocking points in horizontal order and takes the largest square fitting between consecutive blockers. An optimal empty square can be moved or expanded until boundaries or obstacles constrain it, so these support strips suffice. Boundary contacts follow the statement's convention. The implementation by Codex (GPT-6) enumerates vertical supports and scans vertical gaps. Swapping axes yields the horizontal scan above, with the same support-line proof. With $k$ obstacles, both take $O(k^3)$ time and $O(k)$ space. ## Enumerate the left and right boundaries The grid is large but has few buildings. Collect all building column coordinates together with virtual boundaries $0,m+1$ , then sort and deduplicate them. For every pair $l