Perspectives I
Minecraft is a game about mining resources and building structures out of cubes. After a long day of mining diamonds on the ACPC Minecraft server, Saadan is feeling rich and wants to show off his wealth to his friends, Shashwat and Hamza.
To flex, he crafts his diamonds into blocks and builds a structure that is exactly 1 block tall. He then takes two screenshots to share on Discord:
One from the front view (the XY-plane)
One from the side view (the YZ-plane)
From these two perspectives, it is not immediately clear how many diamond blocks Saadan's structure actually contains. Hamza, impressed, wants to determine the maximum possible number of blocks that could match both screenshots.
For example, if the screenshots look like:
Then Saadan's structure could contain at most 15 diamond blocks, as shown below:
Input
The first line contains an integer (
), the number of columns visible in each screenshot.
The second line contains a string of length
, representing the front view (the XY-plane, indexes = X).
The third line contains a string of length
, representing the side view (the YZ-plane, indexes = Z).
Each character of and
is either:
#
: A diamond block.
: Empty space
Output
Output the maximum number of diamond blocks Saadan could have used in this structure, given these two perspectives.
Clarifications
- Each perspective will have at least 1 diamond block.
Example
Input 1
6
###.##
..###.
Output 1
15
This is the example as given above.
Input 2
8
########
########
Output 2
64
Input 3
4
#.##
#.#.
Output 3
6
Comments