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

Hint

思路:

找了好长时间的规律最终失败 后来想起来可以先把符合正视图的坐标保存起来 然后通过后面两个视图筛 听学长说这就是模拟

开三维数组 模拟空间的x、y、z的坐标 感觉很神奇 ……

但自己敲的时候 因为没好好找坐标原点导致自己超级混乱 又看到给出的点和下面的视图并不是相同方向的 就不知所措了

仔细想了想其实这样给点是超级巧妙的:

建立如图坐标系:

在第一组数据中 描述x和y的关系 输入的点中左上角代表原点(真的是空间坐标原点) 向右为y 向下为x 均从零依次增大  再去标记点岂不是很容易

同理 第二次输入z和y的关系 左上角依然是原点

所以建立坐标系一定要找准原点 不然就像刚开始那样乱找关系 容易错误

AC代码:

#include<stdio.h>
#include<string.h>
const int MAX=1e2;
int main()
{
int a[MAX+5][MAX+5][MAX+5],x,y,z;
while(~scanf("%d%d%d",&x,&y,&z)){
memset(a,0,sizeof(a));
int sum=0; ///标记的总个数-后来删去的个数=最终结果 开始是最后重新跑了
for(int i=0;i<x;i++){ ///次循环判断个数 但T了 只好这样改了
for(int j=0;j<y;j++){
int num;
scanf("%d",&num);
if(num==1){
for(int k=0;k<z;k++){
a[i][j][k]=1;
sum++; ///符合主视图 条件的所有点的个数
}
}
}
}
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
int num;
scanf("%d",&num);
if(num==0){
for(int k=0;k<x;k++){
if(a[k][i][j]==1){
a[k][i][j]=-1;
sum--; ///从原来标记的点中删去不符合侧视图的点
}
}
}
}
}
for(int i=0;i<z;i++){
for(int j=0;j<x;j++){
int num;
scanf("%d",&num);
if(num==0){
for(int k=0;k<y;k++){
if(a[j][k][i]==1){
a[j][k][i]=-1;
sum--; ///从原来标记的点中删去不符合俯视图的点
}
}
}
}
}
printf("%d\n",sum);
}
return 0;
}

Clumsy Keke【模拟+三维数组】的更多相关文章

  1. jquery 根据后台传递过来的三维数组动态生成三级菜单

    根据后台传递过来的三维数组动态生成三级菜单 <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  2. Jni :三维数组处理方法 ,以整形三维数组为例 C++实现

    本文原创,转载请注明地址:http://www.cnblogs.com/baokang/p/4982846.html 关于Jni的基本使用方法,请参阅:Java 调用 C++ (Java 调用 dll ...

  3. C语言三维数组分解

    很多人在学习C的时候,感觉三维数组很难想象,而且不理解深度是什么?做了一个图,帮大家分解一下                                                       ...

  4. Java 一维数组 二维数组 三维数组

    二维数组包含一位数组  三维数组就是在二维数组的基础上,再加一层.把二维数组看做是一维数组就可以了,按照上述理解类推.   下面是 一维 二维 三维数组例子   一维数组: int[] array1 ...

  5. 三维数组——与 宝玉QQ群讨论交流之二

    宝玉 12:27:35 这几天看了大部分大家交的作业,发现一个主要问题还是卡在对三维数组的理解上,之前把三维数组类比成三维空间可能会造成误导 宝玉 12:27:45 其实鞠老师解释的很好: 三维数组 ...

  6. c# 基础之数组(包含三维数组)

    public enum ChessType { White = , None=, Black=, } class Program { static void Main(string[] args) { ...

  7. php三维数组变二维数组

    <?php $result = Array(0 => Array(0 => Array(bid => 41,brealname => 'we教官',cid => 4 ...

  8. C++类实现三维数组算法

    在学习北京大学教授的<程序设计实习 / Practice on Programming>中,遇到了一个习题,花了很长时间研究,现在分享出来: 课题地址:https://class.cour ...

  9. java读取目录下所有csv文件数据,存入三维数组并返回

    package dwzx.com.get; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; ...

随机推荐

  1. iOS私有api检测工具使用

    背景:这两天提审了一款新的APP,由于项目中使用了老版本的TZImagePicker中访问了私有API,导致提审失败. 预审经验分享: https://baijiahao.baidu.com/s?id ...

  2. 加密通信软件Signal 2.92版本编译安装折腾手记(Ubuntu 18.04)

    加密通信软件Signal 2.92版本编译安装折腾手记(Ubuntu 18.04) 前言 加密通信软件Signal是开源的,安全性很高,号称斯诺登也推荐大家使用.既然这么好,那必然会有不少人去尝试复制 ...

  3. NPM——常用命令

    npm init //创建一个package.json | npm init -y //快速全部以默认的方式生成一个package.json ,-y是-yes的缩写 以下方式可按回车默认 name 项 ...

  4. vue-cli中的index.html ,main.js , App.vue的关系

    ###发现不少小伙伴才刚开始接触到这个结构都被绕的迷糊,而发现很多人说的也不是那么准确,那么下面我来说一下是怎么回事### 1.首先我们来看看原生Vue中组件的写法, 我们按照vue-cli的结构按照 ...

  5. 【原创】CentOS 7搭建多实例MySQL8(想要几个搞几个)

    起因 最近项目上开始重构,可能会用到主从加读写分离的情况,就想先在本地搭一个出来试试效果,结果百度一搜出来一大堆,然而自己去踩坑的没几个,绝大多数都是去抄的别人的内容,关键是实际应用中还会出错,浏览器 ...

  6. swiper基本使用

    参数名 类型 是否必填 描述 swiperContainer HTMLElement or string 必选 Swiper容器的css选择器,例如".swiper-container&qu ...

  7. C# HttpClient 使用 Consul 发现服务

    试用了Overt.Core.Grpc, 把 GRPC 的使用改造得像 WCF, 性能测试也非常不错, 非常推荐各位使用. 但已有项目大多是 http 请求, 改造成 GRPC 的话, 工作量比较大, ...

  8. 解决docker创建的elasticsearch-head容器不能连接elasticsearch等问题

    在使用docker创建elasticsearch-head容器去连接elasticsearch的时候,容易出两个问题 1.不能连接elasticsearch 修改elasticsearch.yml文件 ...

  9. Vue 百度地图显示规划路线

    Vue 百度地图显示规划路线 1.首选引入相应的文件(建议单页面引入)(如有问题找上一篇博客园) 2.区别就是需要多引入几根不同的文件 import { BaiduMap, BmScale, BmGe ...

  10. Unity 离线建造系统

    很多游戏,特别是养成类手游,都会有自己独特的建造系统,一个建造装置的状态循环或者说生命周期一般是这样的: 1.准备建造,设置各项资源的投入等 2.等待一段倒计时,正在建造中 3.建造结束,选择是否收取 ...