Image is Everything
Time limit2sMemory limit512 MB
Given the six colored views of an N x N x N cube lattice, find the maximum number of cubes that can exist without contradicting any view.
- Level
Easy3 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
Your new company is building a robot that can hold small lightweight objects. The robot has the intelligence to determine whether an object is light enough to hold. It does this by taking pictures of the object from the 6 cardinal directions, then inferring an upper limit on the object's weight from those images. You must write a program that does this for the robot.
Each object is formed from an N × N × N lattice of cubes, and some of the cubes may be missing. Each 1 × 1 × 1 cube weighs 1 gram, and each cube is painted a single solid color. The object is not necessarily connected.
Input
The input consists of several test cases, each describing one object. Each case begins with a line containing N, the size of the object (1 ≤ N ≤ 10). The next N lines are the N × N views in the order front, left, back, right, top, bottom. Each view is separated by a single space from the view that follows it. The bottom edge of the top view corresponds to the top edge of the front view. The top edge of the bottom view corresponds to the bottom edge of the front view. In each view, colors are single unique capital letters, and a period (.) means the object can be seen through at that location.
The input for the last test case is followed by a line containing 0.
Output
For each test case, print one line with the maximum possible weight of the object, in this format: Maximum weight: W gram(s), where W is the weight in grams.