No tags yet

No tag edit access

Time limit per test: 0.25 second(s)

Memory limit: 262144 kilobytes

Memory limit: 262144 kilobytes

input: standard

output: standard

output: standard

A city is built on the top of a rectangular

The King of Berland has a 3D model of the capital city in his office. This model was made on a special 3D-printer out of plastic. It represents a layout of the capital city, but the scale is smaller, so it's very convenient for the King to examine the model without having to visit the city itself. The King is bored though because the model is colorless, so he wants to paint the model. To calculate the exact amount of required paint he should know the total area of the model's surface.

You have to help the King and write a program that will calculate the required surface area of the given model. While calculating the surface area you should count not only the side surfaces, but also the areas of the top and bottom facets.

The model is given to you as

0", it means there is no building built on the top of this cell.

sample input | sample output |

3 3 111 212 111 | 38 |

sample input | sample output |

3 4 1000 0010 0000 | 12 |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/25/2019 21:40:17 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|