HDU_5538_House Building
House Building
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1958 Accepted Submission(s): 1223
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).
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
3 3
1 0 0
3 1 2
1 1 0
3 3
1 0 1
0 0 0
1 0 1
20

- 计算立方体表面积
- 对于给出的每个高度,先算排除底面的表面积,然后减去旁边四面高度的min就是当前立方体表面积
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long LL ;
typedef unsigned long long ULL ;
const int maxn = 1e3 + ;
const int inf = 0x3f3f3f3f ;
const int npos = - ;
const int mod = 1e9 + ;
const int mxx = + ;
const double eps = 1e- ;
const double PI = acos(-1.0) ; int T, n, m, a[maxn][maxn];
LL ans;
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
while(~scanf("%d",&T)){
while(T--){
ans=;
memset(a,,sizeof(a));
scanf("%d %d",&n,&m);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
scanf("%d",&a[i][j]);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if(a[i][j])
ans+=(*a[i][j]+)
-min(a[i][j],a[i-][j])-min(a[i][j],a[i+][j])
-min(a[i][j],a[i][j-])-min(a[i][j],a[i][j+]);
printf("%lld\n",ans);
}
}
return ;
}
HDU_5538_House Building的更多相关文章
- Building the Testing Pipeline
This essay is a part of my knowledge sharing session slides which are shared for development and qua ...
- BZOJ 4742: [Usaco2016 Dec]Team Building
4742: [Usaco2016 Dec]Team Building Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 21 Solved: 16[Su ...
- Building OpenCASCADE on Debian
Building OpenCASCADE on Debian eryar@163.com Abstract. When you are familiar with OpenCASCADE on Win ...
- Building third-party products of OpenCascade
Building third-party products of OpenCascade eryar@163.com Available distributives of third-party pr ...
- Building OpenCascade on Windows with Visual Studio
Building OpenCascade on Windows with Visual Studio eryar@163.com 摘要Abstract:详细说明OpenCascade的编译配置过程,希 ...
- CentOS 6.3 中安装VirtualBOX增强工具失败:Building the main Guest Additions module[FAILED]
在VirtualBox里安装CentOS系统,会遇到“增强工具”无法正常安装,主要的原因是出在Kernel 库找不到. 错误提示如下: 通过查看日志文件: cat /var/log/vboxadd- ...
- Android Studio在创建/导入项目的时候,一直处于building “XXX”gradle project info的解决办法
Android Studio在新建项目或者导入项目的时候,可能会一直处于building “XXX”gradle project info的状态,而且还取消不了,无奈之下只能干掉进程... 还有一种情 ...
- Download Free Oracle Reports Building Guide eBook
A very nice ebook on building reports in Oracle fusion middleware 11g. This manual is intended for a ...
- 【问题】AndroidStudio导入项目一直卡在Building gradle project infod的最快速解决方案
原因 AndroidStudio导入项目一直卡在Building gradle project info的原因, 是因为导入的这个项目使用的gradle版本与本地已经拥有的gradle版本不一致,导致 ...
随机推荐
- redhat yum替换成CentOS yum 并修改源
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm wge ...
- 第十六周oj刷题——Problem E: B 构造函数和析构函数
Description 在建立类对象时系统自己主动该类的构造函数完毕对象的初始化工作, 当类对象生命周期结束时,系统在释放对象空间之前自己主动调用析构函数. 此题要求: 依据主程序(main函数)和程 ...
- Xcode常见问题
今天真机测试的时候,突然出现了这个错误: not have an architecture that “Administrator”的 iPhone (3) can execute. 原因是我刚刚修 ...
- [未解决]Exception in thread "main" java.lang.IllegalArgumentException: offset (0) + length (8) exceed the capacity of the array: 6
调用这个方法 是报错,未解决 binfo.setTradeAmount(Double.parseDouble(new String(result.getValue(Bytes.toBytes(fami ...
- socket相关函数中断后重试
慢系统调用accept,read,write被信号中断时应该重试.对于accept,如果errno为ECONNABORTED,也应该重试. connect虽然也会阻塞,但被信号中断时不能立即重试,该s ...
- 组建一台计算机5_硬件5 多位存储器&累加器&初始汇编(1)
转载请遵循GNU开源宣言.Copyleft ! <2013>, <http://www.cnblogs.com/sciencefans from buaa 华罗庚班> 阅读此文 ...
- zabbix的agent端的主动模式关键三个参数
如多主机超过300+和队列内容过多,就采用主动模式. [root@web03 zabbix]# egrep -v "^#|^$" zabbix_agentd.conf PidFil ...
- 微信小程序 - toptip效果
在Page顶部下滑一个提示条 , 代码见 /mixins/UIComponent.js ,其中的self 可以认为是微信小程序的Page对象 效果: 默认2秒展示,上移动画隐藏 /** * 展示顶部 ...
- Spring的一种拦截器SimpleUrlHandlerMapping
spring的一种拦截器,用于在XML文件中配置以拦截url,它是以map映射的方式进行拦截.映射是从前台urls到具体后台的beans.同时支持到bean实例和bean名称的映射,后者要求非单实例控 ...
- 通过Hadoop安全部署经验总结,开发出以下十大建议,以确保大型和复杂多样环境下的数据信息安全。
通过Hadoop安全部署经验总结,开发出以下十大建议,以确保大型和复杂多样环境下的数据信息安全. 1.先下手为强!在规划部署阶段就确定数据的隐私保护策略,最好是在将数据放入到Hadoop之前就确定好保 ...