Intermedio30 pts
3D Surface Area
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
2D grid A[i][j] = height (cubes) at cell (i,j). Calculate total surface area of the 3D shape. Formula: Top + Bottom + 4 sides. For each cell: top=1, bottom=1, each side = max(0, height - neighbor_height) if neighbor exists, else = height. Sum all faces. Example: Grid [[1,3,4],[2,2,3],[1,2,4]] → Calculate exposed faces for each cell and sum.
Entrada
First line: H W (space-separated). Next H lines: W space-separated integers each.
Salida
A single integer: the total surface area.
Ejemplo
3 3 1 3 4 2 2 3 1 2 4
Esperado
60
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.