Trees and Wall
CodeChefOpen on judge ↗
A few trees are planted randomly at different cells of a square grid. A masson is told to build walls around all the trees such that - Adjacent walls are perpendicular - Total area bounded by the walls is minimum A 2D matrix of dimension $NXN$ is used to represent the grid with values $0$, $1$ or $2$ where - $0$ indicates an empty cells - $1$ indicates location of a tree - $2$ indicates part of
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start