hdu 5538 House Building(长春现场赛——水题)
题目链接:acm.hdu.edu.cn/showproblem.php?pid=5538
House Building
in a 3D map. Blocks are the basic units of structure in Minecraft, there are many types of blocks. A block can either be a clay, dirt, water, wood, air, ... or even a building material such as brick or concrete in this game.

Figure 1: A typical world in Minecraft.
Nyanko-san is one of the diehard fans of the game, what he loves most is to build monumental houses in the world of the game. One day, he found a flat ground in some place. Yes, a super flat ground without any roughness, it's really a lovely place to build
houses on it. Nyanko-san decided to build on a n×m big
flat ground, so he drew a blueprint of his house, and found some building materials to build.
While everything seems goes smoothly, something wrong happened. Nyanko-san found out he had forgotten to prepare glass elements, which is a important element to decorate his house. Now Nyanko-san gives you his blueprint of house and asking for your help. Your
job is quite easy, collecting a sufficient number of the glass unit for building his house. But first, you have to calculate how many units of glass should be collected.
There are n rows
and m columns
on the ground, an intersection of a row and a column is a 1×1 square,and
a square is a valid place for players to put blocks on. And to simplify this problem, Nynako-san's blueprint can be represented as an integer array ci,j(1≤i≤n,1≤j≤m).
Which ci,j indicates
the height of his house on the square of i-th
row and j-th
column. The number of glass unit that you need to collect is equal to the surface area of Nyanko-san's house(exclude the face adjacent to the ground).
the total number of test cases.
First line of each test case is a line with two integers n,m.
The n lines
that follow describe the array of Nyanko-san's blueprint, the i-th
of these lines has m integers ci,1,ci,2,...,ci,m,
separated by a single space.
1≤T≤50
1≤n,m≤50
0≤ci,j≤1000
2
3 3
1 0 0
3 1 2
1 1 0
3 3
1 0 1
0 0 0
1 0 1
30
20
Figure 2: A top view and side view image for sample test case 1.
题目大意:
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
int t,n,m,k,ans;
int a[110][110];
scanf("%d",&t);
while (t--)
{
memset(a,0,sizeof(a));
scanf("%d%d",&n,&m);
k=0;
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
scanf("%d",&a[i][j]);
if (a[i][j]>0)
k++;
}
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
ans=a[i][j]-a[i][j+1];
if (ans>0)
k+=ans;
}
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
ans=a[i][j]-a[i][j-1];
if (ans>0)
k+=ans;
}
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
ans=a[i][j]-a[i-1][j];
if (ans>0)
k+=ans;
}
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
ans=a[i][j]-a[i+1][j];
if (ans>0)
k+=ans;
}
}
printf ("%d\n",k);
}
return 0;
}
hdu 5538 House Building(长春现场赛——水题)的更多相关文章
- hdu 4813(2013长春现场赛A题)
		
把一个字符串分成N个字符串 每个字符串长度为m Sample Input12 5 // n mklmbbileay Sample Outputklmbbileay # include <iost ...
 - HDU 4813 Hard Code(水题,2013年长春现场赛A题)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4813 签到题. 把一个字符串按照格式输出就可以了,很水 #include <stdio.h> ...
 - HDU 4816 Bathysphere (2013长春现场赛D题)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 2013长春区域赛的D题. 很简单的几何题,就是给了一条折线. 然后一个矩形窗去截取一部分,求最 ...
 - hdu 5078 2014鞍山现场赛  水题
		
http://acm.hdu.edu.cn/showproblem.php?pid=5078 现场最水的一道题 连排序都不用,由于说了ti<ti+1 //#pragma comment(link ...
 - HDU 4821  String(2013长春现场赛I题)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4821 字符串题. 现场使用字符串HASH乱搞的. 枚举开头! #include <stdio.h ...
 - HDU 5531  Rebuild (2015长春现场赛,计算几何+三分法)
		
Rebuild Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
 - HDU 4818 Golden Radio Base (2013长春现场赛B题)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 进制转换. 现场根据题目给的两个公式,不断更新!!! 胡搞就可以了. 现场3A,我艹,一次循环开 ...
 - HDU 4815 Little Tiger vs. Deep Monkey(2013长春现场赛C题)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4815 简单的DP题. #include <stdio.h> #include <st ...
 - HDU 4815 Little Tiger vs. Deep Monkey 2013 长春现场赛C题
		
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4815 [题意] n个题目,每题有各自的分数,A有50%的概率答对一道题目得到相应分数,B想要在至少P的概率 ...
 
随机推荐
- syslog/rsyslog的使用
			
syslogd是Linux下的一个记录日志文件服务.从结构来说,可以理解为这个服务下面有一系列的子服务,例如mail.auth.cron.kern等等,这些子服务对外提供日志记录的功能,而当其它的程序 ...
 - Java IO 学习(二)select/poll/epoll
			
如上文所说,select/poll/epoll本质上都是同步阻塞的,但是由于实现了IO多路复用,在处理聊天室这种需要处理大量长连接但是每个连接上数据事件较少的场景时,相比最原始的为每个连接新开一个线程 ...
 - java gc --- 关键词解释
			
分代gc java的堆内存主要分为young generation与old generation,这两块分开回收.这就是所谓的分代gc 其中young generation又分为一个eden spac ...
 - (8)ftp配置文档
			
1.vsftpd文件夹中的ftpusers文件的作用 它是一个黑名单,ftpusers不受任何配制项的影响 该文件存放的是一个禁止访问FTP的用户列表 管理员不希望一些拥有过大权限的帐号(比如root ...
 - HYSBZ 2818 Gcd【欧拉函数/莫比乌斯】
			
I - Gcd HYSBZ - 2818 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. Input 一个整数N Output 如题 Sample In ...
 - ansible 通过网络下载和上传文件
			
1.通过http下载文件,并且不验证证书 - name: download files by https get_url: url: https://robin.org.cn/test.zip des ...
 - Unique Binary Search Trees II - LeetCode
			
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
 - 聊聊、Zookeeper 客户端 ZkClient
			
[ZkClient] ZkClient 是 GitHub 上一个开源的客户端,如果我们用 Maven 来管理工程,则引用如下. <dependency> <groupId>o ...
 - Android 获取虚拟按键的高度
			
//获取虚拟按键的高度 public static int getNavigationBarHeight(Context context) { int result = 0; if (hasNavBa ...
 - EasyMvc入门教程-基本控件说明(12)栏目导航
			
栏目导航一般用来显示当前页面所在的模块层级位置关系,如下图所示: 当然也有前端网站作为小栏目导航,凡是没有绝对,只要不违和就好:),下面上代码: @{ var data = new List<N ...
 
			
		