2019中山大学程序设计竞赛(重现赛) 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
解题思路:这道题就是给你三视图,叫你求体积;
(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的更多相关文章
- 2019中山大学程序设计竞赛 Triangle
今天水了一发hdu上的中山校赛 这个题交了将近十遍才过...... 就是说给 n 个木棍,如果能找出3个能组成三角形的木棍就输出yes 反之输出no 乍一看很简单 一个排序遍历一遍就好了 但是n值太大 ...
- 2019中山大学程序设计竞赛-Monitor
题目地址 题目大意:给你一个n*m的矩形,在这个矩形内告诉你p个矩形(左下角和右上角坐标),问你q个问题,每次也是给你一个矩形(左下角和右上角坐标),问你每个矩形是否可以被开始给的p个矩形完全覆盖. ...
- 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 G - 彩虹岛套娃
题目描述 俄罗斯套娃是俄罗斯特产的木制玩具,一般由多个一样图案的空心木娃娃一个套一个组成,最多可达十多个,通常为圆柱形,底部平坦可以直立.颜色有红色,蓝色,绿色,紫色等.最普通的图案是一个穿着俄罗斯民 ...
- 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 H - 圣诞节糖果
题目描述 圣诞节临近,彩虹岛的黑心商人
- 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 F - 打铁的箱子
题目描述 作为彩虹岛上最擅长打铁的人,
- 长安大学第四届ACM-ICPC“迎新杯”程序设计竞赛-重现赛 D - 新卡片游戏
题目描述
- 第十四届浙江财经大学程序设计竞赛重现赛--A-A Sad Story
链接:https://www.nowcoder.com/acm/contest/89/A 来源:牛客网 1.题目描述 The Great Wall story of Meng Jiangnv’s Bi ...
- “浪潮杯”第九届山东省ACM大学生程序设计竞赛重现赛 C-Cities
题目描述:There are n cities in Byteland, and the ith city has a value ai. The cost of building a bidirec ...
- 牛客网 湖南大学2018年第十四届程序设计竞赛重现赛 A game
链接:https://www.nowcoder.com/acm/contest/125/A来源:牛客网 Tony and Macle are good friends. One day they jo ...
随机推荐
- js 操作数组的一些方法
1.从数组中获取最大的数 function getMaxfromarr(arr) { var lasti = 0; for (var i = 0; i < arr.length; i++) { ...
- svn与eclipse的集成(第三方插件与eclipse的集成)
在eclipse中点击Help,选中install from site..
- css实现文本过长时自动添加省略号
1. 效果 2. Html <div id="main_app_content" class="container"> <div class= ...
- 01 lucene基础 北风网项目培训 Lucene实践课程 Lucene概述
lucene-core-2.4.1.jar是lucene开发的核心jar包,lucene-analyzers-2.4.1.jar也是必不可少的.lucene-highlighter-2.4.1.jar ...
- Python学习笔记_使用openpyxl操作Excel,在同一个文件里复制某一个sheet
应用场景:定制一个Excel模板文件,其中定义了一个模板Sheet,以此模板文件里的模板sheet为样例,制作报表,里面有不止一个模板样例Sheet 一.软件环境: 1.OS:Win10 64位 2. ...
- SqlServer垂直分表 如何减少程序改动
当单表数据太多时,我们可以水平划分,参考 SqlServer 分区视图实现水平分表 ,水平划分可以提高表的一些性能. 而 垂直分表 则相对很少见到和用到,因为这可能是数据库设计上的问题了.如果数据库中 ...
- Java线程同步的方法
如果向一个变量写值,而这个变量接下来可能会被另一个线程所读取,或者从一个变量读值,而它的值可能是前面由另一个线程写入的,此时就必须使用同步. sychronized Java语言的关键字,当它用来修饰 ...
- #error用法
#error命令是C/C++语言的预处理命令之一,当预处理器预处理到#error命令时将停止编译并输出用户自定义的错误消息. 语法: #error [用户自定义的错误消息] 注:上述语法成份中的方括号 ...
- 洛谷 P1103 书本整理(动规)
洛谷 P1103 书本整理 题目描述 Frank是一个非常喜爱整洁的人.他有一大堆书和一个书架,想要把书放在书架上.书架可以放下所有的书,所以Frank首先将书按高度顺序排列在书架上.但是Frank发 ...
- Qcreator3.1.2调试器(windows)版本
环境:visual studio 2012 qt:5.3.1 默认的ms版本qtcreator只能使用visual studio的编译器,不能使用调试工具.需要gdb或者cdb进行调试,这里介绍使用的 ...