Clumsy Keke

Problem Description

Keke is currently studying engineering drawing courses, and the teacher has taught her how to find its volume through the three views of the part. But her brain doesn't work well that she can't find the volume of complex parts. So she needs your help.

To simplify the problem, the part is made up of cubes with side length 1 , and the vertices of these cubes are all on the grid. Give you three 0/1 matrices, each representing each of the three views. 0 means that there is no projection of cubes at this position of the view; 1 means that there is a projection of cubes at this position of the view.

Now Keke wants you to help her find the volume of the part determined by the three views.

 

 

Input

There are mutiple test cases, the number of which is no more than 10. For each test case:

The first line of input contains three integers mx,my,mz(1≤mx,my,mz≤99) , which represent the coordinate range of all possible cubes (i.e. all possible cubes are in the cuboid area whose body diagonal is from (1,1,1) to (mx,my,mz) ).

Following input a 0/1 matrix with mx lines and my columns representing the front view, and the y -th column of the x -th row represents the projection of all the cubes in the front view such as (x,y,?) .

Following input a 0/1 matrix with my lines and mz columns representing the side view, and the z -th column of the y -th row represents the projections of all the cubes in the side view such as (?,y,z) .

Following input a 0/1 matrix with mz lines and mx columns representing the top view, and the x -th column of the z -th row represents the projection of all the cubes of the top view such as (x,?,z) .

The '? ' in the above coordinates represents any integer. Numbers in the same line are separated by spaces. For more detailed input information, please see the sample.

 

 

Output

For each test case:

The first line of output should contain an integer, representing the volume of the part determined by the three views. If the determined part is not unique, find the largest of all possible parts.

Keke's teacher promises that there is at least one part that satisfies the input.

 

 

Sample Input

 

5 6 4 1 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1

 

 

Sample Output

 

17

思路简单模拟 

阴影部分去掉即可

代码:

#include<iostream>
using namespace std;
int a[109][109][109];
int a1;
int a2;
int a3;
int main()
{
	int n,m,k;
	while(~scanf("%d%d%d",&n,&m,&k))
	{
		for(int i = 1;i <= n;++i)
		{
			for(int j = 1;j <= m;++j)
			{
				for(int z = 1;z <= k;++z)
				{
					a[i][j][z] = 1;
				}
			}
		}
		for(int i = 1;i <= n;++i)
		{
			for(int j = 1;j <= m;++j)
			{
				scanf("%d",&a1);
				if(a1 == 0)
				{
					for(int h = 1; h <= k;++h)
					{
						a[i][j][h] = 0;
					}
				}
			}
		}
		
		for(int i = 1;i <= m;++i)
		{
			for(int j = 1;j <= k;++j)
			{
				scanf("%d",&a2);
				if(a2 == 0)
				{
					for(int h = 1; h <= n;++h)
					{
						a[h][i][j] = 0;
					}
				}
			}
		}
		for(int i = 1;i <= k;++i)
		{
			for(int j = 1;j <= n;++j)
			{
				scanf("%d",&a3);
				if(a3 == 0)
				{
					for(int h = 1; h <= m;++h)
					{
						a[j][h][i] = 0;
					}
				}
			}
		}
		int sum = 0;
		for(int i = 1;i <= n;++i)
		{
			for(int j = 1;j <= m;++j)
			{
				for(int z = 1;z <= k;++z)
				{
					if(a[i][j][z] == 1)
					{
						sum++;
					}
				}
			}
		}
		printf("%d\n",sum);	
	}
	
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-lyslyslys

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值