Back
Close
  • 151

Statement

 Goal

François designs above-ground swimming pools for the bourgeoisie. His designs are represented by an NxN grid of letters, with heights ranging from A=1 to Z=26. Find the volume of water each pool can hold.
Input
Line 1: The size N of the grid.
Next N lines: The grid values.
Output
The volume of water that the pool can hold. Outside the pool the height is 0, so no water is held on the cells at the edge of the pool. The water does not leak diagonally. You can think of the puzzle as a bunch of blocks, take a look at the cover picture for illustration.
Constraints
10 ≤ N ≤ 40
Example
Input
10
ZZZZZZZZZZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZAAAAAAAAZ
ZZZZZZZZZZ
Output
1600

A higher resolution is required to access the IDE