编程介的小学生 2017-08-29 03:46 采纳率: 20.5%
浏览 1055
已采纳

Bob's new toy

Bob used to have many toy blocks and he loved cube blocks very much and build many structures only using cube blocks. Now, Bob has new toys to play, a set of magnetic robs with different length and magnetic balls to connect these robs. He decide to use these new toys to reproduce those structure he used to build using cube blocks by replacing every cube block with the cube frame below.

As you can see, each block is composed by 8 magnetic balls, 12 magnetic robs with length 1(standard rob). And there would be some magnetic robs with length √2 (long rob) connecting to diagonal balls to make it rigid. Adjacent cubes can share balls and robs. Before long he realize that there is no need to put 3 long robs to connect the diagonal balls of each cube to make it rigid. For example, if the structure is a 2 × 2 × 2 cube, only 9 robs is need to prevent the structure from out of its shape.

If there are less than 9 long robs, for example, 8 long rods, the structure may transform into the shape showed in pictures below so it cannot maintain its original shape.

Bod wonder what is the minimum number of long robs need to prevent the structure from out of the shape.

Input

There are multiple cases. The first line of each case contains three integers, H, L and W (1 ≤ H, L, W ≤10), indicating the height ,length and width of the structure built by original cube blocks. Then H section of input followed, each section contains L lines and each line contains W character describing the layout of the structure. The wth character of lth line in the hth section is '*' when there is a cube block in position (w,l,h), or '.' otherwise.

Sections are separated by a blank line. The input structure is guaranteed to be connected by faces and there would be at least one '*' in each case. Please note that the final structure is built by replacing each cube block by robs and balls, as mentioned above.

Output

For each case, output one integer, the minimum number of long robs Bob needed to make the structure rigid.

Sample Input

1 2 3



1 2 3
.


2 2 2
**
**

**
**
3 3 3










3 3 3





.





Sample Output

9
11
9
15
15

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-12 16:40
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘