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

解题思路:这道题就是给你三视图,叫你求体积;

(1)首先题给的这个正视图和侧视图不是真实图的正视图和侧视图,所以应该翻转一下;

 

(2)此时就暴力的枚举每个小块,如果都为1,那么就ans++;这样不会出现重复的情况;

代码如下:

 #include<iostream>
#include<stdio.h>
using namespace std; int m , n , k;
int x[][];
int y[][];
int z[][];
int tpx[][];
int tpy[][];
int ans = ;
int main()
{
while(scanf("%d%d%d",&m,&n,&k)!=EOF)
{
ans = ;
for(int i = ; i <= m ; i++)
{
for(int j = ; j <= n ; j++)
{
cin>>x[i][j];
}
}
for(int i = ; i <= n ;i++)
{
for(int j = ;j <= k ;j++)
{
cin>>y[i][j];
}
}
for(int i = ; i <= k ; i ++)
{
for(int j = ; j <= m ;j++)
{
cin>>z[i][j];
}
} for(int i = ; i <= n ; i++)
{
for(int j = ; j <= m ;j++)
{
tpx[i][j] = x[j][n-i+] ; //向左翻转
}
} for(int i = ; i <= n ;i++)
{
for(int j = ;j <= k ;j++)
{
tpy[i][j] = y[n-i+][j]; //上下翻转
}
}
for(int i = ; i <= m ;i++)
{
for(int j = ; j <= n ;j++)
{
for(int l = ; l <= k ;l++)
{
if(tpx[j][i]==&&z[l][i]==&&tpy[j][l]==)
{
ans++;
}
}
}
} cout<<ans<<endl; }
}

2019中山大学程序设计竞赛(重现赛) Clumsy Keke的更多相关文章

  1. 2019中山大学程序设计竞赛 Triangle

    今天水了一发hdu上的中山校赛 这个题交了将近十遍才过...... 就是说给 n 个木棍,如果能找出3个能组成三角形的木棍就输出yes 反之输出no 乍一看很简单 一个排序遍历一遍就好了 但是n值太大 ...

  2. 2019中山大学程序设计竞赛-Monitor

    题目地址 题目大意:给你一个n*m的矩形,在这个矩形内告诉你p个矩形(左下角和右上角坐标),问你q个问题,每次也是给你一个矩形(左下角和右上角坐标),问你每个矩形是否可以被开始给的p个矩形完全覆盖. ...

  3. 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 G - 彩虹岛套娃

    题目描述 俄罗斯套娃是俄罗斯特产的木制玩具,一般由多个一样图案的空心木娃娃一个套一个组成,最多可达十多个,通常为圆柱形,底部平坦可以直立.颜色有红色,蓝色,绿色,紫色等.最普通的图案是一个穿着俄罗斯民 ...

  4. 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 H - 圣诞节糖果

    题目描述 圣诞节临近,彩虹岛的黑心商人

  5. 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 F - 打铁的箱子

    题目描述 作为彩虹岛上最擅长打铁的人,

  6. 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 D - 新卡片游戏

    题目描述

  7. 第十四届浙江财经大学程序设计竞赛重现赛--A-A Sad Story

    链接:https://www.nowcoder.com/acm/contest/89/A 来源:牛客网 1.题目描述 The Great Wall story of Meng Jiangnv’s Bi ...

  8. “浪潮杯”第九届山东省ACM大学生程序设计竞赛重现赛 C-Cities

    题目描述:There are n cities in Byteland, and the ith city has a value ai. The cost of building a bidirec ...

  9. 牛客网 湖南大学2018年第十四届程序设计竞赛重现赛 A game

    链接:https://www.nowcoder.com/acm/contest/125/A来源:牛客网 Tony and Macle are good friends. One day they jo ...

随机推荐

  1. re模块之re.match

    re模块--python 正则表达式 正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达 ...

  2. 基于NodeJS的14款Web框架

    摘要: 在几年的时间里,Node.js逐渐发展成一个成熟的开发平台,吸引了许多开发者.有许多大型高流量网站都采用Node.js进行开发,像PayPal, 此外,开发人员还可以使用它来开发一些快速移动W ...

  3. Kafka总结的一张图

  4. 【LA3211 训练指南】飞机调度 【2-sat】

    题意 有n嫁飞机需要着陆.每架飞机都可以选择“早着陆”和“晚着陆”两种方式之一,且必须选择一种.第i架飞机的早着陆时间为Ei,晚着陆时间为Li,不得在其他时间着陆.你的任务是为这些飞机安排着陆方式,使 ...

  5. [Unity Shader笔记]渲染路径--Forward渲染路径

    [Unity Shader笔记]渲染路径--Forward渲染路径 (2014-04-22 20:08:25) 转载▼ 标签: shader unity renderingpath forward 游 ...

  6. Go语言特性

    1.入口,go有且只有一个入口函数,就是main函数 liteide (IDE)的 一个工程(文件夹)只能有且只有一个main函数 package main import "fmt" ...

  7. ubuntu下学习linux

    ---恢复内容开始--- 查看当前正在运行的进程(ps命令, grep 搜索命令) ps -ef # -e 显示所有进程,环境变量 -f 全格式 也可以用: ps -e -f # 显示所有关于java ...

  8. Integer中getInteger(),valueof()

    Integer类有两个看起来很类似的静态方法,一个是Integer.getInteger(String),另外一个是Integer.valueOf(String).如果只看方法名称的话,很容易将这两个 ...

  9. ObjC正则表达式验证

    试过ObjC的regkit这个框架. 也用过内置的正则表达式验证. 最后发现有个非常简单的方法就可以做到验证正则表达式.那就是NSPredicte这个类提供的方法. 这里有验证邮箱地址的正则为例: N ...

  10. android在更新ADT以后报java.lang.NoClassDefFound的解决办法

    Android不是很熟.从网上找到了想要的代码后兴高采烈的导入workspace中,直接开Run. but在真机的时候Console.LogCat下都没显示什么有用的东西,就是写NDK编译完Nativ ...