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;
}

最新文章

  1. ns3 print 丢包内容的两种方法
  2. bootstrap之google fonts
  3. 移动端web开发总结
  4. 搭建 Hexo Blog
  5. COGS738 [网络流24题] 数字梯形(最小费用最大流)
  6. Async详解之一:流程控制
  7. Oracle wrap 测试的一些细节问题
  8. 教你6步定制你的Ubuntu桌面
  9. js_day1
  10. 国内的阿里云MAVEN仓库,速度很快
  11. php使用curl设置超时的重要性
  12. 04.redis集群+SSM整合使用
  13. CentOS7用hostapd做radius服务器为WiFi提供802.1X企业认证
  14. 在pycharm中每次运行代码不使用console而使用run
  15. JAVA记录-Web系统AJAX异步传递路径写法
  16. linux 远程执行命令
  17. bzoj 1419 Red is good - 动态规划 - 概率与期望
  18. Unity中利用光线投射实现摄像机拉近追踪对象
  19. Lua中的注释
  20. BZOJ1012最大数 [JSOI2008] 单调栈+二分

热门文章

  1. 用window.print()打印如何去掉页眉和页脚
  2. YYTimer学习笔记
  3. Educational Codeforces Round 56 (Rated for Div. 2) F. Vasya and Array
  4. D. Almost Acyclic Graph 判断减一条边能不能得到DAG
  5. 花6个月写的付费专栏,免费送|仿开源框架从零到一完整实现高性能、可扩展的RPC框架
  6. 基于 kubeadm 搭建高可用的kubernetes 1.18.2 (k8s)集群 部署 dashboard 2.x
  7. 【Java8新特性】关于并行流与串行流,你必须掌握这些!!
  8. RocketMQ安装及入门
  9. Dell KACE K1000 poc
  10. SpringBoot 2.x 版本以put方式提交表单不生效的问题详解